Rails 3 routing: a map with options?

I cannot find documentation on mapping routes with parameters in rails 3.

As a specific example, I need to translate

map.with_options :controller => 'users' do |signup|
    signup.signup '/signup',
      :action => 'landing',
      :conditions => { :method => :get }
    signup.premium '/signup/premium',
      :action => 'new',
      :level => 'premium',
      :conditions => { :method => :get }    
    signup.premium '/signup/premium',
      :action => 'create',
      :level => 'premium',
      :conditions => { :method => :post }
    signup.free '/signup/free',
      :action => 'new',
      :level => 'free',
      :conditions => { :method => :get }    
    signup.free '/signup/free',
      :action => 'create',
      :level => 'free',
      :conditions => { :method => :post }      
  end

In the correct syntax for rails3. I am sure it should be just that I forgot, but any help or links to articles would be wonderful.

+5
source share
3 answers
scope '/signup' do
    match '/signup' => "users#landing", :as => :signup
    get '/:level' => 'users#new', :as => :signup_new
    post '/:level' => 'users#create', :as => :signup_create
end

This is exactly what I was looking for, at first it was not clear (for me) that this is how the options will be translated.

+4
source

read http://guides.rails.info/index.html (edge ​​rails docs) to find out how you can translate your 2.x route rails

0
source
scope '/signup' do
 with_options :controller => :users do |signup|
    signup.match '/signup', :action => :landing
    signup.get '/:level', :action => :new, :as => :signup_new 
      # or just signup.get '/:level/new', :action => :new
    signup.post '/:level', :action => :create, :as => :signup_create
 end
end
0

All Articles