title: undefined method or my Active Record mistakes
body: <p>Sorry if my problem will be silly but Rails are new to me. I made two models and two controllers. My problems were started after I made second model and added reference to the first one.</p>
  
  <pre><code>class SentencesController &lt; ApplicationController
      before_action :find_story
  
      def create      
          @sentence = find_story.sentences.build(sentence_params)
          if @sentence.save
             flash[:success] = "You wrote the continuation!"
             render 'stories/show'
          else
            render 'stories/show'
          end
      end
  
    private
  
      def sentence_params
        params.require(:sentence).permit(:content)
      end
  
      def find_story
          @story = Story.find(params[:id])
      end
  end
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>class StoriesController &lt; ApplicationController 
  
  ........
  
      def show
          @story = Story.find(params[:id])
          @sentence = @story.sentences.build
      end 
  
  .........
  
  
  end
  </code></pre>
  
  <p>And I have a problem with defining instance variable @story = Story.find(params[:id]). Error: ActiveRecord::RecordNotFound in SentencesController#create. I have tried many combinations.</p>
  
  <p>This is my migrate files:</p>
  
  <pre><code>class CreateStories &lt; ActiveRecord::Migration[5.1]
    def change
      create_table :stories do |t|
        t.string :title
        t.text :content
  
        t.timestamps
      end
    end
  end
  
  class CreateSentences &lt; ActiveRecord::Migration[5.1]
    def change
      create_table :sentences do |t|
        t.text :content
        t.references :story, foreign_key: true
  
        t.timestamps
      end
      add_index :sentences, [:story_id, :created_at]
    end
  end
  </code></pre>
  
  <p>What did I do wrong?</p>
  
  <p>EDIT (routes):</p>
  
  <pre><code>Rails.application.routes.draw do
      root 'stories#index'
      get 'stories/show'
    get 'stories/new'
    resources :stories
    resources :sentences, only: [:create]
  end
  </code></pre>
  
  <p>and schema:</p>
  
  <pre><code>ActiveRecord::Schema.define(version: 20180322121215) do
  
    create_table "sentences", force: :cascade do |t|
      t.text "content"
      t.integer "story_id"
      t.datetime "created_at", null: false
      t.datetime "updated_at", null: false
      t.index ["story_id"], name: "index_sentences_on_story_id"
    end
  
    create_table "stories", force: :cascade do |t|
      t.string "title"
      t.text "content"
      t.datetime "created_at", null: false
      t.datetime "updated_at", null: false
    end
  
  end
  </code></pre>