I wanna use rails REST so:
resources :questions
I wanna add a route /questions/query_by_student so:
resources :questions, :collection => { :query_by_student => :get }
now I want /que开发者_StackOverflow社区stions/query_by_student/1 this 1 shoule be student`s id .What I should do? Even more,I want the request which post to /questions/query_by_student/1 meet another action...
我想用rails的REST 于是:
resources :questions
我想添加一个/questions/query_by_student 于是:
resources :questions, :collection => { :query_by_student => :get }
现在我想/questions/query_by_student/1 这个1是student的id 我要怎么写?Try this in your routes.rb
match ':controller/:id/:action'
Your controller would have:
def query_by_student
@student = Student.find(params[:id])
...
end
精彩评论