views:

44

answers:

2

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.

A: 

read http://guides.rails.info/index.html (edge rails docs) to see how you can translate your rails 2.x routes

apeacox
Thanks but I'd already read all of this, I was hoping for a specific example.
Evan Cordell
+1  A: 
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.

Evan Cordell
I would add that I need to add constraints to these to only allow free and premium as options for the level, but that's relatively trivial.
Evan Cordell
thanks! been looking everywhere for this
stephenmurdoch