Some background: I have a Posts controller which is used for users to create or update posts. In a post form, a user starts writing their post. This post can either be saved as a draft (and then the form switches functionality to submit to the “update” action of the controller) and later be posted to a page, or be directly posted to a page.
These forms post remotely to a page, which appends a table with the post inside.
Currently, I have a problem: submitting a form breaks down because, in appending the table, I get an error “ActionView::Template::Error (No route matches {:action=>”vote”, :controller=>”posts”, :post_id=>245, :positive=>true})”. This refers to a line of code in the posts view:
<%= link_to (image_tag("icons/upvote.png", :height => "15px")), vote_post_path(:post_id => post.id, :positive => true), :remote => true %>
I should mention that appending the post to the table is done by using an @post variable that remains available from the controller.
NOW the weird thing is that this error ONLY occurs when a post has been submitted directly to the “create” action, and trying to append the table with the post. When a saved draft is submitted to the “update” action and appended onto the table, this doesn’t occur.
Does anyone have any advice as to why this is? I can provide more code where relevant.
EDIT: the relevant section of my routes file:
resources :posts do
member do
get :vote
end
end
the problem is that you have the “vote” action as a member action, not a collection action. Switch it to: