views:

67

answers:

1

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

A: 

The RESTful way to do this is:

Route:

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

Controller

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

end
Steve Graham
Thanks, but this does not satisfy my constraints. I want to send a parameter to the "update" method, not create a new method called "publish". Also, what is RESTful about creating a non-CRUD method on the controller?
Luke Griffiths