I have following rails3 routes that I want to convert into rails4.
map.with_options(:conditions => {:subdomain => AppConfig['admin_subdomain']}) do |subdom|
subdom.root :controller => 'subscription_admin/subscriptions', :action => 'index'
subdom.with_options(:namespace => 'subscription_admin/', :name_prefix => 'admin_', :path_prefix => nil) do |admin|
...
end
end
Rails RESTful Design which creates seven routes all mapping to the user controller. Rails also allows you to define multiple resources in one line.
Rails routing is a two-way piece of machinery – rather as if you could turn trees into paper, and then turn paper back into trees. Specifically, it both connects incoming HTTP requests to the code in your application's controllers, and helps you generate URLs without having to hard-code them as strings.
rb . The Rails router recognises URLs and dispatches them to a controller's action. It can also generate paths and URLs, avoiding the need to hardcode strings in your views. Let's consider an application to book rooms in different Hotels and take a look at how this works.
namespace :admin do
constraints subdomain: AppConfig['admin_subdomain'] do
root to: 'subscription_admin/subscriptions#index'
namespace :subscription_admin do
resources :some_resources
# RESTful routes
end
end
end
end
More info about constrains.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With