title: Create comments for two models from comments controller ruby on rails
body: <p>Ruby on rails newbie here, I have previously been using CakePHP and wanted to allow my create comments controller to create events for two models, any help please?</p>
  
  <p>My comments controller:</p>
  
  <pre><code>def create
      @event = Event.find(params[:event_id])
      @comment = @event.comments.create(params[:comment].permit(:commenter, :body))
      redirect_to event_path(@event)
    end
  
    def create
       @venue = Venue.find(params[:venue_id])
       @comment = @venue.comments.create(params[:comment].permit(:commenter, :body))
       redirect_to venue_path(@venue)
    end
  </code></pre>
  
  <p>My create comments view: </p>
  
  <pre><code>&lt;h2&gt;Add a comment:&lt;/h2&gt;
  &lt;%= form_for([@event, @event.comments.build]) do |f| %&gt;
    &lt;p&gt;
      &lt;%= f.label :commenter %&gt;&lt;br /&gt;
      &lt;%= f.text_field :commenter %&gt;
    &lt;/p&gt;
    &lt;p&gt;
      &lt;%= f.label :body %&gt;&lt;br /&gt;
      &lt;%= f.text_area :body %&gt;
    &lt;/p&gt;
    &lt;p&gt;
      &lt;%= f.submit %&gt;
    &lt;/p&gt;
  &lt;% end %&gt;
  </code></pre>