Reputation: 4118
I can't seem to find documentation on mapping routes with options 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
Into proper syntax for rails3. I'm sure it must be simple that I've overlooked, but any help or links to articles would be wondrous.
Upvotes: 5
Views: 4113
Reputation: 7669
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
Upvotes: 0
Reputation: 4118
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 specifically what I was looking for, it was unclear at first (to me) that this is how options would translate.
Upvotes: 4
Reputation: 5311
read http://guides.rails.info/index.html (edge rails docs) to see how you can translate your rails 2.x routes
Upvotes: 0