title: Rails 4: First argument in form cannot contain nil or be empty
body: <p>In our Rails 4 app, there are four models:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    has_many :administrations, dependent: :destroy
    has_many :calendars, through: :administrations
  end
  
  class Administration &lt; ActiveRecord::Base
    belongs_to :user
    belongs_to :calendar
  end
  
  class Calendar &lt; ActiveRecord::Base
    has_many :administrations, dependent: :destroy
    has_many :users, through: :administrations
  end
  
  class Post &lt; ActiveRecord::Base
      belongs_to :calendar
  end
  </code></pre>
  
  <p>We have routed the corresponding resources with <a href="http://edgeguides.rubyonrails.org/routing.html#routing-concerns" rel="nofollow">Routing Concerns</a>, as follows:</p>
  
  <pre><code>concern :administratable do
    resources :administrations
  end
  
  resources :users, concerns: :administratable
  resources :calendars, concerns: :administratable
  </code></pre>
  
  <p>To create a new <code>@calendar</code>, we use the following form:</p>
  
  <pre><code>&lt;h2&gt;Create a new calendar&lt;/h2&gt;
  &lt;%= form_for(@calendar) do |f| %&gt;
    &lt;%= render 'shared/error_messages', object: f.object %&gt;
    &lt;div class="field"&gt;
      &lt;%= f.text_field :name, placeholder: "Your new calendar name" %&gt;
    &lt;/div&gt;
    &lt;%= f.submit "Create", class: "btn btn-primary" %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>When we embed this form into the user's show.html.erb (so that a user can create a new calendar from his profile), everything works fine.</p>
  
  <p>However, we would like to have a special page, call dashboard, where a user could see all his calendars and create a new one.</p>
  
  <p>We believe the logical url should be /users/:id/administrations.</p>
  
  <p>So, we embedded the above form in the Administration's index.html.erb.</p>
  
  <p>And as soon as we do that and visit for instance /users/1/administrations, we get the following error:</p>
  
  <pre><code>ArgumentError in AdministrationsController#index
  
  First argument in form cannot contain nil or be empty
  
  Extracted source (around line #432):
  
  else
    object      = record.is_a?(Array) ? record.last : record
    raise ArgumentError, "First argument in form cannot contain nil or be empty" unless object
    object_name = options[:as] || model_name_from_record_or_class(object).param_key
    apply_form_for_options!(record, object, options)
  end
  </code></pre>
  
  <p><strong>EDIT</strong>: here is also our Administrations#Controller:</p>
  
  <pre><code>class AdministrationsController &lt; ApplicationController
  
    def to_s
      role
    end
  
    def index
      @user = current_user
      @administrations = @user.administrations
    end
  
    def show
      @administration = Administration.find(params[:id])
    end
  
  end
  </code></pre>
  
  <p>Any idea of what we are doing wrong?</p>