Custom Routes

Hi, I am busy with a tourism website and I am almost done, but the
URL’s is starting to bug me…
I am still a Rails noob, but I am eager to learn as much as possible.
I already make use of resource
routes, but I want to display the paths like this: /countries/
zimbabwe, and: admin/countries/southafrica
instead of something like: /countries/1… Is this possible?

And would you encourage someone to use routes in that custom way?

One last thing: Is named routes also part of the RESTful routes?

Thanks! I really appreciate your dedication to help others :slight_smile:

map ‘countres/:name’, :controller => a, :action => b

class a < ActiveController
def b
params[:name]
end
end

Hi,
As you want country name instead of id than pass name field. and in
show method you have to search according to country name instead of id.

As you required admin as prefix. so create namespace and define 

routes as
map.namespace :admin do |admin|
admin.resources :countries
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs