The make_resourceful plugin is a great way to DRY up the 7 RESTful actions common in most controllers. Learn how to use it in this episode.
# products_controller.rb
make_resourceful do
actions :all
response_for :show do |format|
format.html
format.xml { render :xml => current_object.to_xml }
end
end
private
def current_objects
Product.find(:all, :order => 'name')
end
def current_object
@current_object ||= Product.find_by_permalink(params[:id])
end
<!-- edit.html.erb -->
<%= hidden_field_tag '_flash[notice]', "Successfully updated product." %>