title: Variable passing to use path in partial
body: <p>I'm learning Ruby on Rails by using this <a href="https://www.railstutorial.org/book/" rel="nofollow noreferrer">book</a>.
  I'm stuck on the second exercise from <a href="https://www.railstutorial.org/book/updating_and_deleting_users#sec-exercises_edit_form" rel="nofollow noreferrer">here</a>.</p>
  
  <p>My form partial <code>app/views/users/_form.html.erb</code> looks like this:</p>
  
  <pre><code>&lt;%= form_for(@user, url: yield(:path)) do |f| %&gt;
    &lt;%= render 'shared/error_messages', object: @user %&gt;
  
    &lt;%= f.label :name %&gt;
    &lt;%= f.text_field :name, class: 'form-control' %&gt;
  
    &lt;%= f.label :email %&gt;
    &lt;%= f.email_field :email, class: 'form-control' %&gt;
  
    &lt;%= f.label :password %&gt;
    &lt;%= f.password_field :password, class: 'form-control' %&gt;
  
    &lt;%= f.label :password_confirmation %&gt;
    &lt;%= f.password_field :password_confirmation, class: 'form-control' %&gt;
  
    &lt;%= f.submit yield(:button_text), class: "btn btn-primary" %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>My signup view <code>app/views/users/new.html.erb</code> with partial is this:</p>
  
  <pre><code>&lt;% provide(:title, 'Sign up') %&gt;
  &lt;% provide(:button_text, 'Create my account') %&gt;
  &lt;% provide(:path, signup_path) %&gt;
  &lt;h1&gt;Sign Up&lt;/h1&gt;
  &lt;div class="row"&gt;
    &lt;div class="col-md-6 col-md-offset-3"&gt;
      &lt;%= render 'form' %&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and my edit view <code>app/views/users/edit.html.erb</code> is this:</p>
  
  <pre><code>&lt;% provide(:title, "Edit user") %&gt;
  &lt;% provide(:button_text, "Save changes") %&gt;
  &lt;% provide(:url, user_path) %&gt;
  &lt;h1&gt;Update your profile&lt;/h1&gt;
  &lt;div class="row"&gt;
    &lt;div class="col-md-6 col-md-offset-3"&gt;
      &lt;%= render 'form' %&gt;
      &lt;div class="gravatar_edit"&gt;
        &lt;%= gravatar_for @user %&gt;
        &lt;a href="http://gravatar.com/emails" target="_blank" rel="noopener noreferrer"&gt;Change&lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My problem is that I don't know which right path for the <strong>edit view</strong> I have to set with the <strong>provide</strong> method.</p>
  
  <p>With <strong>signup_path</strong> it works fine for the signup view. What I tried for the edit view is:</p>
  
  <ul>
  <li><code>user_path</code> (currently in the code example) </li>
  <li><code>edit_user_path</code></li>
  <li><code>edit_user_path(@user)</code> (to pass the user object)</li>
  </ul>
  
  <p>Below the current routing error I got:</p>
  
  <p><a href="https://i.stack.imgur.com/u5TxV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u5TxV.png" alt="enter image description here"></a></p>
  
  <p>and below that the available routes related to user:</p>
  
  <p><a href="https://i.stack.imgur.com/u4TVG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u4TVG.png" alt="enter image description here"></a></p>
  
  <p>For example if I don't use provide for the edit view to provide an url, it works fine like here:</p>
  
  <pre><code>&lt;%= form_for(@user) do |f| %&gt;
    &lt;%= render 'shared/error_messages', object: @user %&gt;
  
    &lt;%= f.label :name %&gt;
    &lt;%= f.text_field :name, class: 'form-control' %&gt;
  
    &lt;%= f.label :email %&gt;
    &lt;%= f.email_field :email, class: 'form-control' %&gt;
  
    &lt;%= f.label :password %&gt;
    &lt;%= f.password_field :password, class: 'form-control' %&gt;
  
    &lt;%= f.label :password_confirmation %&gt;
    &lt;%= f.password_field :password_confirmation, class: 'form-control' %&gt;
  
    &lt;%= f.submit yield(:button_text), class: "btn btn-primary" %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>But the goal is to refactor the code using partials, so I need to provide an url for the signup view.</p>
  
  <p>The <code>routes.rb</code>:</p>
  
  <pre><code>Rails.application.routes.draw do
    get 'sessions/new'
  
    get 'users/new'
  
    root 'static_pages#home'
    get    '/help',    to: 'static_pages#help'
    get    '/about',   to: 'static_pages#about'
    get    '/contact', to: 'static_pages#contact'
    get    '/signup',  to: 'users#new'
    post   '/signup',  to: 'users#create'
    get    '/login',   to: 'sessions#new'
    post   '/login',   to: 'sessions#create'
    delete '/logout',  to: 'sessions#destroy'
    resources :users
  end
  </code></pre>