嗨,我正试图通过以下链接到erb线路调用我的方法报价:-
<%= link_to "Offer Bid", {:controller => "bids", :action => "offer_bid"},
:remote => true %>
但我得到了以下路由错误:-
No route matches {:action=>"offer_bid", :controller=>"bids"}.
我应该在routes.rb文件中显式定义路由吗????
当我运行“rake route s”时,我有如下对应的链接到的路由:-
rake routes | grep bid
post_bids GET /posts/:post_id/bids(.:format) {:controller=>"bids", :action=>"index"}
post_bids POST /posts/:post_id/bids(.:format) {:controller=>"bids", :action=>"create"}
new_post_bid GET /posts/:post_id/bids/new(.:format) {:controller=>"bids", :action=>"new"}
edit_post_bid GET /posts/:post_id/bids/:id/edit(.:format) {:controller=>"bids", :action=>"edit"}
post_bid GET /posts/:post_id/bids/:id(.:format) {:controller=>"bids", :action=>"show"}
post_bid PUT /posts/:post_id/bids/:id(.:format) {:controller=>"bids", :action=>"update"}
post_bid DELETE /posts/:post_id/bids/:id(.:format) {:controller=>"bids", :action=>"destroy"}
/bids/:bid_id(.:format) {:controller=>"bids", :action=>"offer_bid"}
注意与action=>“offer\u bid”对应的路径名只是一个空白!!!
为什么这里是空白的???
我试图调用的方法如下:-
def offer_bid
@bid = Bid.find(params[:id])
@post.bid_winner_id = @bid.user_id
@post.save
flash[:notice] = "Task offered to @post.user.email"
end
为实现我的用例所做的任何解释和建议都是非常感谢的。
提前谢谢。
我使用的是rails版本3.01