Reputation: 899
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
Upvotes: 0
Views: 362
Reputation: 3021
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
Upvotes: 0