Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If the form is included for multiple actions (pages) you need to set @shiftchange to something or the form_for directive will fail (it won't have anything to create a form for).</p> <p>A much better approach (and the Rails default) is to have separate views for each action, each including only the elements required by that action, and loaded into your <code>application.html.erb</code> layout with <code>&lt;%= yield %&gt;.</code> So you would have a <code>app/views/shiftchanges/new.html.erb</code> view which has the form in it. You never very rarely need to define any load paths in Rails, they are all derived from the <code>model, controller and action</code> names - or from your <code>routes.rb</code>. This is a core part of the <code>convention over configuration</code><a href="http://en.wikipedia.org/wiki/Convention_over_configuration" rel="nofollow">http://en.wikipedia.org/wiki/Convention_over_configuration</a> paradigm which runs so deep in Rails.</p> <p>If you do need to have a form for creating a new object on every page (often used for ShiftchangeSessions for example), you can rewrite your form_for so that it doesn't depend on an object being present:</p> <pre><code>form_for(Shiftchange.new) </code></pre> <p>or if you need to force it to post to the create method</p> <pre><code>form_for(Shiftchange.new, :url =&gt; { :action =&gt; "create" }) </code></pre> <p>You can read more about resource driven <code>form_for</code> in the Ruby On Rails API docs <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_for-label-Resource-oriented+style" rel="nofollow">http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_for-label-Resource-oriented+style</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload