In the ERB for scaffold generators in Rails 4.2 from where do the variables / methods come from in the template?
Things like singular_table_name and attributes in the below '_form.html.erb' template. Are they methods? variables? where can I find a list of what is available for use in this template?
I tried using some ActiveRecord class methods for example (reflections) and they were not available.
If it is only a set list of methods, not drawn from the AR class, is there a way to pass instance variables from the generators like you would from a controller to a view?
Originally from .rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/generators/erb/scaffold/templates/_form.html.erb
I now placed this file (which works) in rails_app/lib/templates/erb/scaffold
<%%= form_for(@<%= singular_table_name %>) do |f| %>
<%% if @<%= singular_table_name %>.errors.any? %>
<div id="error_explanation">
<h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
<ul>
<%% @<%= singular_table_name %>.errors.full_messages.each do |message| %>
<li><%%= message %></li>
<%% end %>
</ul>
</div>
<%% end %>
<% attributes.each do |attribute| -%>
<div class="field">
<% if attribute.password_digest? -%>
<%%= f.label :password %><br>
<%%= f.password_field :password %>
</div>
<div class="field">
<%%= f.label :password_confirmation %><br>
<%%= f.password_field :password_confirmation %>
<% else -%>
<%%= f.label :<%= attribute.column_name %> %><br>
<%%= f.<%= attribute.field_type %> :<%= attribute.column_name %> %>
<% end -%>
</div>
<% end -%>
<div class="actions">
<%%= f.submit %>
</div>
<%% end %>