title: Undefined method link_to_edit using Draper decorator
body: <p>I've got a User and Post models, which are related to each other in a classical way -- <code>User has_many :posts</code> and <code>Post belongs_to :user</code>. In my <code>users#show</code>, where I display a user's profile, I also have a list of all posts he has made. Also, I wanted to have links to edit and delete each post respectfully. So, I made up with this:</p>
  
  <pre><code>&lt;% @user.posts.each do |post| %&gt;
    &lt;h1&gt;&lt;%= link_to post.title, post_path(post) %&gt;&lt;/h1&gt;
    &lt;% if @user == current_user %&gt;
        &lt;%= link_to 'Edit', edit_post_path(post) %&gt;
        &lt;%= link_to 'Delete', post_path(post), method: :delete %&gt;
    &lt;% end %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>But surely placing this logic into view results in a mess, so I decided to use Draper and write decorators for that. As we are going to check rights for <code>posts#edit</code> and <code>posts#delete</code> methods, I came up with a decorator for Post model and tried to use it in <code>PostsController</code>. Here it goes:</p>
  
  <pre><code>class PostDecorator &lt;&lt; Draper::Decorator
    delegate_all
  
    def link_to_edit
      if object.user == current_user
        h.link_to 'Edit', h.edit_post_path(object)
      end
    end
  
    def link_to_delete
      if object.user == current.user
        h.link_to 'Delete', h.post_path(object), method: :delete
      end
    end   
  end
  </code></pre>
  
  <p>Then, in my <code>PostsController</code>:</p>
  
  <pre><code># ... class definition
  before_action :set_post, only: [:show, :edit, :update, :destroy]
  
  # ... other controller methods
  def edit; end
  
  def update
    if @post.update(post_params)
      @post.save
      redirect_to post_path(@post)
    else
      render 'edit'
    end
  end
  
  def destroy
    @post.destroy
    redirect_to feed_path
  end
  
  private
  
  # Using FriendlyId gem to have neat slugs
  def set_post
    @post = Post.friendly.find(params[:id]).decorate
  end
  </code></pre>
  
  <p>But every time I try to render my User profile with list of his posts, with the use of my new helpers <code>&lt;%= post.link_to_delete %&gt;</code> and <code>&lt;%= post.link_to_edit %&gt;</code> instead of that conditional mess, it just returns me the following error:</p>
  
  <p><a href="https://i.stack.imgur.com/jDz1u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jDz1u.png" alt="error"></a> </p>
  
  <p>What am I doing wrong?</p>