Passing Vars to Partials and yield


#1

I have the following partial

<%= form_for(@user, url: path) do |f| %>
  <%= render 'shared/error_messages', object: @user %>

  <%= f.label :name %>
  <%= f.text_field :name, class: 'form-control' %>

  <%= f.label :email %>
  <%= f.email_field :email, class: 'form-control' %>

  <%= f.label :password %>
  <%= f.password_field :password, class: 'form-control' %>

  <%= f.label :password_confirmation %>
  <%= f.password_field :password_confirmation, class: 'form-control' %>

  <%= f.submit yield(:button_text), class: "btn btn-primary" %>
<% end %>

It’s called in this view:

<% provide(:title, 'Sign up') %>
<% provide(:button_text, 'Create my account') %>
<% provide(:url, signup_path) %>
<h1>Sign up</h1>
<div class="row">
  <div class="col-md-6 col-md-offset-3">
    <%= render 'form', :path => yield(:url) %>
  </div>
</div>

The way I got it working was by including <% provide(:url, signup_path) %> and :path =>yield(:url). Why did I need to use yield and provide here? Why couldn’t I simply pass signup_path to the locals hash that was being sent to the partial?