I have a form to update an item called post, but i need a different method than开发者_如何学Python update because there are 2 ways to update the post, i have tried this in a lot of ways but i only get this error
No route matches "/topics/1/posts/35/completed"
the controller:
def completed
@post.download_remote_image
respond_to do |format|
if @post.save
format.html { redirect_to topic_path(@topic), :notice => t('.post_created') }
else
format.html { render :action => :edit }
end
end
end
the view part:
= form_for [@topic, @post], :url => completed_topic_post_path(@topic, @post) do |f|
the routes:
resources :topics do
resources :posts do
get 'complete', :as => :complete
post 'completed', :as => :completed
end
end
Thanks !!
:url => completed_topic_post_path(@topic, @post) needs to be :url => topic_post_completed_path(@topic, @post)
精彩评论