Hello. I had such a problem: when I try to edit a post, this error appears:
undefined method `post_path' for Here is the code in the Posts controller:
def edit @post = Post.find(params[:id]) end Here is routes.rb:
resources :users do resources :posts end Here is the link that leads to the form with editing:
<%= link_to 'Редактировать', edit_user_post_path %> Well, the form itself, upon transition to which this error occurs (the edit.html.erb file):
<% = form_for @post do | f | %> and so on. (this line is indicated as an error)
UPDATE At random changed the form to
<%= form_for :post, url: user_post_path(:post), method: :put do |f| %> and in the controller I left the edit method empty:
def edit end Now everything works and the question is closed. But in Rusrails, the edit method is not empty, the form is:
<%= form_for :post, url: post_path(@post.id), method: :patch do |f| %> Maybe it is possible in the new 4 rails? On 3 does not work like this.