Help: Adding rating to existing posts model in Rails -
There is a simple post model with my title: string and rating: integer and I want to add the ability to rate the post . So far I have
# post controller def increase @ post = post.find (params [: id]) @ post.increment! : Rating Flash [: Notice] = "Thank you for your rating." Redirect_to @post end #Post Show & lt;% = link_to "Rating", increase_post_path%> & gt; # Path map.resources: post, member = & gt; {: Rise = & gt; : Put}
When I click on Rating, I get an unknown action when I add @ post.increment, then I am able to increase the rating! : To update the rating, but when I create my own method
map, if a standard route is saying then map. Source: Post
You should change this with:
map.resources: posts, member = & gt; {: Rise = & gt; : Put}
and it will create the "incre_post_path" path for your app with the "put" method.
Comments
Post a Comment