And*_*rew 5 controller ruby-on-rails
在我的Rails 3.0应用程序中,我在我的资源上有一系列非常大的搜索表单:索引页面,需要使用POST而不是GET.
目前,应用程序将POST请求路由到资源#create,当我希望它路由到资源#index时.我意识到这是RESTful路由,但需要覆盖它.我怎么能这样做,同时还保留了创建该资源的新记录的能力?
非常感谢.
您最好进行仅发布的“搜索”操作,然后呈现索引模板,例如:
class MyController < ...
def search
@my_things = MyThing.find_with_search_params(params[:search])
render :action => :index
end
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4006 次 |
| 最近记录: |