开发者

Is there any specific article about every options of REST in rails?

开发者 https://www.devze.com 2023-04-13 08:56 出处:网络
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 }

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号