Rails Workflow
Today, I made a couple (tiny) Rails apps.
Granted, Rails generators handled a lot of the black magic; but I was able to establish a simple workflow to get up and running quickly, and I would like to share it with you.
Do the following in your terminal. Use vim. Be a rockstar.
Rails Workflow #
A few simple steps when starting a new Rails project #
rails new <app_name>
Update Gemfile to include gems for testing
- e.g. RSpec, FactoryGirl, Capybara
group :development, :test do gem "rspec-rails" end group :test do gem "capybara" gem "launchy" gem "factory_girl_rails" gem "database_cleaner" end
Commit
Generate RSpec stuff
bundle exec rails generate rspec:install
Commit
Generate controller
rails generate controller <controller_name>
Generate model
rails generate model <model_name>
Commit
Write a (failing) controller test inside spec/controllers/
vim spec/controllers/*_controller_spec.rb
Commit
Update routes in config/routes.rb
get '/jiggy' => 'willenium#dance'
Commit
Add controller actions (methods) model that satisfy controller test
def dance @jig = Jig.create(jig_params) end private def jig_params params.require(:jig).permit(:style, :level) end