title: undefined method `song_id' [rails 4]
body: <p>To break down my app quickly: I have a songs, comments, and users model. User's can upload songs, and make comments. </p>
  
  <p>In short, when submitting a song I get the below error.I've looked into how Ryan Bates does does and my code is identical. Not sure why the song_id isn't being associated. Please advise :)</p>
  
  <p>Full app code can be seen here: www.github.com/apane/leap</p>
  
  <p><strong>Error msg:</strong></p>
  
  <pre><code>NoMethodError in Songs#show
  
  Showing /Users/apane/Downloads/leap/app/views/comments/_form.html.erb where line #17 raised:
  
  undefined method `song_id' for #&lt;Song:0x007f8e71f77d10&gt;
  
  &lt;div class="row"&gt;
  &lt;div class="large-6 columns"&gt;
  &lt;div class="field"&gt;
  &lt;%= f.hidden_field :song_id %&gt;
  &lt;p&gt;
  &lt;%= f.label :author_name, 'Name' %&gt;&lt;br /&gt;
  &lt;%= f.text_field :author_name %&gt;
  </code></pre>
  
  <p><strong>comments#_form.html.erb</strong></p>
  
  <pre><code>&lt;%= form_for @comment do |f| %&gt;
    &lt;% if @comment.errors.any? %&gt;
      &lt;div id="error_explanation"&gt;
        &lt;h2&gt;&lt;%= pluralize(@comment.errors.count, "error") %&gt; prohibited this comment from being saved:&lt;/h2&gt;
  
        &lt;ul&gt;
        &lt;% @comment.errors.full_messages.each do |msg| %&gt;
          &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt;
        &lt;% end %&gt;
        &lt;/ul&gt;
      &lt;/div&gt;
    &lt;% end %&gt;
  
      &lt;div class="row"&gt;
          &lt;div class="large-6 columns"&gt;
    &lt;div class="field"&gt;
       &lt;%= f.hidden_field :song_id %&gt;
        &lt;p&gt;
          &lt;%= f.label :author_name, 'Name' %&gt;&lt;br /&gt;
          &lt;%= f.text_field :author_name %&gt;
        &lt;/p&gt;
        &lt;p&gt;
          &lt;%= f.label :site_url, 'Website URL' %&gt;&lt;br /&gt;
          &lt;%= f.text_field :site_url %&gt;
        &lt;/p&gt;
        &lt;p&gt;
          &lt;%= f.label :content, 'Comment' %&gt;&lt;br /&gt;
          &lt;%= f.text_area :content, :rows =&gt; '12', :cols =&gt; 35 %&gt;
        &lt;/p&gt;
        &lt;p&gt;&lt;%= f.submit "Submit" %&gt;&lt;/p&gt;
      &lt;% end %&gt;
      &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
  </code></pre>
  
  <p><strong>songs_controller.rb</strong></p>
  
  <pre><code>class SongsController &lt; ApplicationController
    before_filter :authenticate_user!, only: [:create ,:edit, :update, :destroy]
    before_action :set_song, only: [:show, :edit, :update, :destroy]
  
    # GET /Songs
    # GET /Songs.json
    def index
      @songs = Song.all
    end
  
    # GET /Songs/1
    # GET /Songs/1.json
    def show
      @comment = @song
    end
  
    # GET /Songs/new
    def new
      @song = Song.new
    end
  
    # GET /Songs/1/edit
    def edit
    end
  
    # POST /Songs
    # POST /Songs.json
    def create
      @song = Song.new(song_params)
  
      respond_to do |format|
        if @song.save
          format.html { redirect_to @song, notice: 'Song was successfully created.' }
          format.json { render action: 'show', status: :created, location: @song }
        else
          format.html { render action: 'new' }
          format.json { render json: @song.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # PATCH/PUT /Songs/1
    # PATCH/PUT /Songs/1.json
    def update
      respond_to do |format|
        if @song.update(song_params)
          format.html { redirect_to @song, notice: 'Song was successfully updated.' }
          format.json { head :no_content }
        else
          format.html { render action: 'edit' }
          format.json { render json: @song.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # Song /Songs/1
    # Song /Songs/1.json
    def destroy
      @song.destroy
      respond_to do |format|
        format.html { redirect_to songs_url }
        format.json { head :no_content }
      end
    end
  
    private
  
      def set_song
         @song = Song.find(params[:id])
       end
  
       def song_params
         params.require(:song).permit(:title, :artist, :bio, :track, :user_id)
       end
    end
  </code></pre>
  
  <p><strong>comments_controller.rb</strong></p>
  
  <pre><code>class CommentsController &lt; ApplicationController
    before_action :set_comment, only: [:show, :edit, :update, :destroy]
  
  
  
    # GET /comments/new
    def new
    end
  
    # GET /comments/1/edit
    def edit
    end
  
    # POST /comments
    # POST /comments.json
    def create
      @comment = Comment.new(comment_params)
  
      respond_to do |format|
        if @comment.save
          format.html { redirect_to song_url(@comment.song_id), notice: 'Comment was successfully created.'  }
          format.json { render action: 'show', status: :created, location: @comment}
        else
          format.html { render action: 'new' }
          format.json { render json: @comment.errors, status: :unprocessable_entity }
        end
      end
    end
  
  
    # PATCH/PUT /comments/1
    # PATCH/PUT /comments/1.json
    def update
      respond_to do |format|
        if @comment.update(comment_params)
          format.html { redirect_to song_url(@comment.song_id), notice: 'Comment was successfully updated.' }
          format.json { head :no_content }
        else
          format.html { render action: 'edit' }
          format.json { render json: @comment.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # DELETE /comments/1
    # DELETE /comments/1.json
    def destroy
      @comment.destroy
        redirect_to song_url(@comment.song_id)
      end
  
    private
      # Use callbacks to share common setup or constraints between actions.
      def set_comment
        @comment = Comment.find(params[:id])
      end
  
      # Never trust parameters from the scary internet, only allow the white list through.
      def comment_params
        params.require(:comment).permit(:song_id, :author_name, :site_url, :content, :user_id)
      end
  end
  </code></pre>
  
  <p><strong>songs#show.html.erb</strong> </p>
  
  <pre><code>&lt;p id="notice"&gt;&lt;%= notice %&gt;
  
  
      &lt;p&gt;
      &lt;strong&gt;Title:&lt;/strong&gt;
      &lt;%= @song.title %&gt;
      &lt;/p&gt;
  
      &lt;p&gt;
      &lt;strong&gt;Bio:&lt;/strong&gt;
      &lt;%= @song.bio %&gt;
      &lt;/p&gt;
  
      &lt;p&gt;
      &lt;strong&gt;Audio:&lt;/strong&gt;
      &lt;%= audio_tag (@song.track.url), controls: "controls", alt: "Please use chrome, ie, or safari" %&gt;
      &lt;/p&gt;
  
  
      &lt;br /&gt;&lt;br /&gt;
  
  
      &lt;%= link_to 'Edit', edit_song_path(@song), class: "button small secondary"%&gt; 
      &lt;%= link_to 'Back', songs_path,  class: "button small secondary" %&gt;
  
  
      &lt;% unless @song.comments.empty? %&gt;
        &lt;h2&gt;&lt;%= pluralize(@song.comments.size, 'comment') %&gt;&lt;/h2&gt;
  
        &lt;div id="comments"&gt;
        &lt;% for comment in @song.comments %&gt;
          &lt;div class="comment"&gt;
            &lt;strong&gt;&lt;%= link_to_unless comment.site_url.blank?, h(comment.author_name), h(comment.site_url) %&gt;&lt;/strong&gt;
            &lt;em&gt;on &lt;%= comment.created_at.strftime('%b %d, %Y at %H:%M') %&gt;&lt;/em&gt;
            &lt;%=simple_format comment.content %&gt;
            &lt;p&gt;
                &lt;%= link_to "Edit", edit_comment_path(comment) %&gt;
              &lt;% end %&gt;
                | &lt;%= link_to "Destroy", comment, :method =&gt; :delete, :confirm =&gt; "Are you sure?" %&gt;
            &lt;/p&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;% end %&gt;
  
      &lt;h3&gt;Add your comment:&lt;/h3&gt;
      &lt;%= render :partial =&gt; 'comments/form' %&gt;
  </code></pre>