Skip to content

Instantly share code, notes, and snippets.

@knowuh
Created September 23, 2011 13:05
Show Gist options
  • Save knowuh/1237284 to your computer and use it in GitHub Desktop.
Save knowuh/1237284 to your computer and use it in GitHub Desktop.
generating help_request Model, View, Controller, Tests, and route:
# there is a 'generator' to run which will create all of our boilerplate
# code for the 'help request'
./script/generate cc_rspec_haml_scaffold HelpRequest email:string login:string name:string class_name:string activity:string no_students:int computer_type:string os:string browser:string ip_address:string problem_type:string all_computers:bool pre_loaded:bool more_info:text logfile:text referrer:text
# clearer to view fields if its broken up:
./script/generate cc_rspec_haml_scaffold HelpRequest\
email:string \
login:string \
name:string \
class_name:string \
activity:string \
no_students:int \
computer_type:string \
os:string \
browser:string \:
ip_address:string \
problem_type:string \
all_computers:bool \
pre_loaded:bool \
more_info:text \
logfile:text \
referrer:text
# this command generates the following files:
# Controller:
# app/controllers/help_requests_controller.rb
# Model:
# app/models/help_request.rb
# Views:
# app/views/help_requests/_form.html.haml
# app/views/help_requests/_remote_form.html.haml
# app/views/help_requests/_show.html.haml
# app/views/help_requests/edit.html.haml
# app/views/help_requests/index.html.haml
# app/views/help_requests/show.html.haml
# View Helper:
# app/helpers/help_requests_helper.rb
# Migration file:
# db/migrate/20110923004732_create_help_requests.rb
# Tests:
# spec/controllers/help_requests_controller_spec.rb
# spec/helpers/help_requests_helper_spec.rb
# spec/models/help_request_spec.rb
# spec/routing/help_requests_routing_spec.rb
# spec/views/help_requests/edit.html.erb_spec.rb
# spec/views/help_requests/index.html.erb_spec.rb
# spec/views/help_requests/new.html.erb_spec.rb
# spec/views/help_requests/show.html.erb_spec.rb
# It also adds a line to the top of the routes file:
# config/routes.rb
# Then I remove some unused files:
rm spec/integration/help_requests_spec.rb
rm spec/fixtures/help_requests.yml
# then run the database migration which was
# bundle exec rake db:migrate will run all 'pending' migrations
# including newly generated db/migrate/20110923004732_create_help_requests.rb
bundle exec rake db:migrate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment