Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert rails3 routes into rails4

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
like image 778
Dipak Panchal Avatar asked Oct 30 '15 17:10

Dipak Panchal


People also ask

How many types of routes are there in Rails?

Rails RESTful Design which creates seven routes all mapping to the user controller. Rails also allows you to define multiple resources in one line.

How do routes work in Rails?

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.

What is routes RB in Rails?

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.


1 Answers

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.

like image 189
Andrey Deineko Avatar answered Sep 30 '22 01:09

Andrey Deineko