Category Archives: Ruby on Rails

Ruby – Problem while scaffold – routes.rb needs to have the action name

I got a serious problem when scaffold in ruby and couldn’t get the route working with different action rather than auto generated actions. I had controller name search and action zea. It was working fine while I hit it. But while create an action named nokogiri, it wasnt working. I searched it to google and stackoverflow with ruby – problem with routes.rb in scaffold and got some results. It suggested to add a line in routes.rb

get "searches/nokogiri"

But it wasnt working simply because of the serialized sequence of the line of code for custom action. it was previously

resources :searches
  get "searches/nokogiri"

But it should be

get "searches/nokogiri"
resources :searches

get should be before resources, It is working fine right now.

Ruby on Rails common Command / Instruction

Following are some common command / instruction that I have been using last 15 days as new ruby on rails developer.

1. To check Ruby Version

ruby -v

2. To create new rails project

rails new projectName

3. To start rails server

rails server

or

rails s

4. To generate model or controller

rails generate controller controllerName
rails generate model modelName

you can see the  what generate can do by the command

rails generate

. it will show like this

Rails:
assets
controller
generator
helper
integration_test
mailer
migration
model
observer
performance_test
resource
scaffold
scaffold_controller
session_migration
task

5. To create db or migrate db

rake db:create
rake db:migrate

6. You can also generate migration

rails generate migration migrationName

7. To go to db version or migrate to a version

rake db:migrate VERSION=version_number

8.Run server on different port

rails server -e development -p 3001