ruby - Rails routes, how to specify this member proper -


i have routes following:

  resources :contests     member       :enter     end   end 

this allows me http on url looks /contests/5/enter. now, user can go in, fill in forms, , able submit entry contest. i'd able post url. tried doing following:

 resources :contests         member           :enter           post :enter         end       end 

this posts same controller#action member have specified, it's not intuitive. i'd able direct separate action if @ possible. what's best way of doing that? using ruby on rails 4 beta currently.

** update **

i tried following argumenterror exception when start server:

resources :contests     member       :enter       post :enter => "contests#create_entry"     end   end 

you can this:

resources :contests   member     :enter     post '/enter', to: "contests#create_entry", as: "create_entry"   end end 

however agree ola tuvesson, should create new controller , routes entries, though may not have model, similiar how have session controller login , logout. this:

resources :contests   resources :entries, only: [:new, :create] end 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -