Forum: Ruby on Rails help in updating the code " Head First Ruby on Rails"

0af700f522b87da4afe9da0895dd773e?d=identicon&s=25 Małgorzata Bąk (magorzata_b)
on 2014-03-11 14:18
I would like understood routes, scaffolding etc. "Head First Ruby on
Rails" has a very old Rails. I am working with Rails 4. On 93 page "Head
First Ruby on Rails"/polish edition/Helion 2010
there is:
ActionController::Routing::Routes.draw do |map|
map.connect '/ads/:id', :controller=> 'ads', :action=>'show'
map.connect ':controller/:action/:id'
map.conect ':controller/:action/:id.:format'

In "Agile Web Development in Rails 4" there is something different
and I do not know, how change to Rails4 the cod of "Head First Ruby on
on the 92 page  "Agile Web Development in Rails 4 - in English, 2013" is
something like this:
Download rails40/depot_d/config/routes.rb
Depot::Application.routes.draw do
get "store/index"
resources :products


Could Anybody help me to change/write in Rails4 the project's
A47e0a6beeb9d048ff054fc1c3a97418?d=identicon&s=25 Walter Davis (walterdavis)
on 2014-03-11 14:44
(Received via mailing list)
There's a free course at that goes through the
entire process of building a Rails application (and along the way,
understanding what Rails is and does and doesn't do).

0af700f522b87da4afe9da0895dd773e?d=identicon&s=25 Małgorzata Bąk (magorzata_b)
on 2014-03-11 15:55
thank you
B2ea0545dc3b54e877f4a36be4fcde89?d=identicon&s=25 Gustavo Caso (Guest)
on 2014-03-18 11:10
(Received via mailing list)
El martes, 11 de marzo de 2014 14:18:26 UTC+1, User
> etc...
> Could Anybody help me to change/write in Rails4 the project's
> config/routes.rb?
> --
> Posted via

Basically since the upgrade to rails 4.
map has been deprecated, instead is more secure to specify the HTTP verb
the route GET, POST, PUT, PATCH, DELETE, also rails use the CRUD
that stand for Create, Read, Update, Delete, this the basic actions that
rails provide inside our controller when doing a scaffold, also Index,
So when creating the routes you have to specify a URL, which goes to a
controller and an action.


get           'store/index',        to: 'store#index',          as:

HTTP             URL             controller#action              name

the name part will give you some helper methods: store_url and
Usually when creating a scaffold it will generate in your routes files a
line like this resources :store, which will provide all the routes for

This is a link explaining everything
Hope I helped you.
0af700f522b87da4afe9da0895dd773e?d=identicon&s=25 Małgorzata Bąk (magorzata_b)
on 2014-03-18 15:29
Thank You for response. MB
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.