lundi 13 novembre 2017

How to routes to a specific controller with a variable value ahead of it in rails 5?

Normally its like: resources :users To keep a value ahead we can do like

scope :url do
   resources :users
end

but, problem is that I have the just variable in front of the routes not a fixed value. Example in rails 2. and want to convert the routing accoding to rails5

map.with_options :controller => 'users' do |user|
  user.forgot_user ':url/users/forgot',   :action => 'forgot',  :url => /([a-zA-Z0-9\-]*)/
  user.user ':url/users/retrieve',   :action => 'retrieve',  :url => /([a-zA-Z0-9\-]*)/
  user.login       ':url/users/login',    :action => 'login',                                          :url => /([a-zA-Z0-9\-]*)/
  user.logout      ':url/users/logout',   :action => 'logout',                                         :url => /([a-zA-Z0-9\-]*)/
  user.new_user    ':url/users/new',      :action => 'new',     :conditions => { :method => :get },    :url => /([a-zA-Z0-9\-]*)/
  user.users       ':url/users/:id',      :action => 'show',   :conditions => { :method => :get },    :url => /([a-zA-Z0-9\-]*)/
end

Aucun commentaire:

Enregistrer un commentaire