0

I want to have this exact named route that I can put in views:

<%= link_to publish_review_path(@review) %>

... I would like it to map to a path like this:

"/reviews/3456/publish"

... and then when that pattern is matched, have the following sent to the controller:

{ 
  :controller => "reviews", 
  :action => "update", 
  :id => "3456", 
  :aasm_event => "publish"
 }

How can I do this?

As a constraint, I need to be able to do this using

instea map.resources :reviews

4

1 回答 1

0

执行此操作的 RESTful 方式是:

路线:

map.resources :reviews, :member => { :publish => :put }

控制器

def publish
  @review = Review.find(params[:id])
  @review.publish!
  respond_to do |format|
   format.html { redirect_to @review }
   …

end
于 2009-12-09T10:55:44.177 回答