title: Rails form that requires multiple parameters from different models
body: <p>I'm currently practicing how to make a pedigree system, I have successfully implemented users who own dogs, but I want those users to be able to create a pedigree relationship to other dog's profiles like in pic related:
  <a href="http://imgur.com/swjlelH" rel="nofollow">My view</a></p>
  
  <p>My issue is that when I click the Submit button to create the relationship (or at least know if it works) I get a "The action 'new' could not be found for PedigreeController" error message. Here is my controller and as you can see I only have a create and a destroy method. I tried changing the url in the view to create but without luck. I have also added resources :pedigree to my route file.</p>
  
  <pre><code> class PedigreeController &lt; ApplicationController
    def create
      @dog = Dog.find(params[:dog_id])
      #@pedigree = pedigrees.build(dog_id: @dog.id, relative_id: @dog.id, relation_name: :string)
      @pedigree = @dog.build_pedigree(pedigree_params)
      if @pedigree.save
        flash[:success] = "Dog relative added."
        redirect_to access_dogmenu_path
      else
        flash[:danger] = "Unable to add this dog as relative"
        redirect_to access_dogmenu_path
      end
    end
  
    def destroy
      @pedigree = @dog.pedigrees.find(params[:id])
      @pedigree.destroy
      flash[:success] = "Relative removed."
      redirect_to access_dogmenu_path
    end
  
    private
  
    def pedigree_params
      params.require(:pedigree).permit(:dog_id, :relative_id, :relation_name)
    end
  end
  </code></pre>
  
  <p>I have made a pedigree.rb model which is used to create the dogs relationships.</p>
  
  <pre><code>class Pedigree &lt; ActiveRecord::Base
    belongs_to :dog
    belongs_to :relative, class_name: Dog
  end
  </code></pre>
  
  <p>This is the dog.rb model</p>
  
  <pre><code>class Dog &lt; ActiveRecord::Base
    belongs_to :user
    has_many :pedigrees
    has_many :relatives, through: :pedigrees, dependent: :destroy
  end
  </code></pre>
  
  <p>Here is what I have currently in my view (which shows in every dog profile):</p>
  
  <pre><code>...
  &lt;h3&gt;Relatives: &lt;/h3&gt;
    &lt;ul&gt;
     &lt;% for pedigree in @dog.pedigrees %&gt;
       &lt;li&gt;
       &lt;%= pedigree.relative.dname %&gt;'s - &lt;%= pedigree.relative.relation_name %&gt;
                       &lt;%= link_to "Remove", pedigree, method: :delete %&gt;
        &lt;/li&gt;
     &lt;% end %&gt;
     &lt;/ul&gt;
  &lt;h4&gt;Add this dog as your dog's relative: &lt;/h4&gt;
    &lt;%= form_for(Pedigree.new, url: new_pedigree_path) do |p| %&gt;
    Select your dog:
    &lt;%= p.collection_select(:dog_id, @dogs,:id, :dname, :prompt =&gt; "Select your dog") %&gt;&lt;br&gt;
    Select your dog relation to the dog from this profile:
    &lt;%= select_tag(:relation_id, options_for_select([['Sibling', 1], ['Parent', 2], ['Grandparent', 3], ['Great-grandparent', 4], ['Child', 5], ['Grandchild', 6], ['Great-grandchild', 7]])) %&gt;&lt;br&gt;
   &lt;%= p.submit 'Add Relation' %&gt;
   &lt;% end %&gt;
  ...
  </code></pre>
  
  <p>To create a pedigree relation 3 things are needed:</p>
  
  <ol>
  <li><p>The dog_id of the current user's dog of choice (The collection_select seems to be working).</p></li>
  <li><p>The relative_id of the dog that will become a relative, in this case the relative_id should be taken straight from the show page for example <a href="http://localhost:3000/dogs/2" rel="nofollow">http://localhost:3000/dogs/2</a> would be sending dog_id=2 into the form. <strong>Does anybody know how would I go about including this in my form?</strong></p></li>
  <li><p>the relation_name like sibling, parent, etc. The drop down selector seems to be working ok.</p></li>
  </ol>
  
  <p>Any help is greatly appreciated.</p>