title: NoMethodError in ProductsController#create
body: <p>I am working through "Agile Web Development with Rails 4" and I've run in to this issue in <strong>Chapter 7, Task B: Validation and Unit Testing</strong>. Any help would be appreciated.</p>
  
  <p>When I try to add a new entry this is the error I get.</p>
  
  <hr>
  
  <pre><code>undefined method `titles' for #Product:0x007fa6fcbf28e0
  </code></pre>
  
  <p>Extracted source (around line #30):</p>
  
  <blockquote>
  <pre><code>respond_to do |format|
    if @product.save
      format.html { redirect_to @product, notice: 'Product was successfully created.' }
      format.json { render action: 'show', status: :created, location: @product }
    else
  </code></pre>
    
    <p>if @product.save is line 30.</p>
  </blockquote>
  
  <hr>
  
  <p>This started after adding these lines to my <strong>products.rb</strong> in <strong>/rails/depot_a/app/models</strong></p>
  
  <pre><code>    class Product &lt; ActiveRecord::Base
  validates :titles, :description, :image_url, presence: true
  validates :price, numericality: {greater_than_or_equal_to: 0.01}
  validates :title, uniqueness: true
  validates :image_url, allow_blank: true, format: {
      with: %r{\.(gif|jpg|png)\Z}i,
      message: 'must be a URL for GIF, JPG, or PNG image.'
  }
  end
  </code></pre>
  
  <hr>
  
  <p>This is my <strong>products_controller.rb</strong> in <strong>/rails/depot_a/app/controllers</strong> which was mentioned in the error.</p>
  
  <pre><code>   class ProductsController &lt; ApplicationController
    before_action :set_product, only: [:show, :edit, :update, :destroy]
  
    # GET /products
    # GET /products.json
    def index
      @products = Product.all
    end
  
    # GET /products/1
    # GET /products/1.json
    def show
    end
  
    # GET /products/new
    def new
      @product = Product.new
    end
  
    # GET /products/1/edit
    def edit
    end
  
    # POST /products
    # POST /products.json
    def create
      @product = Product.new(product_params)
  
      respond_to do |format|
        if @product.save
          format.html { redirect_to @product, notice: 'Product was successfully created.' }
          format.json { render action: 'show', status: :created, location: @product }
        else
          format.html { render action: 'new' }
          format.json { render json: @product.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # PATCH/PUT /products/1
    # PATCH/PUT /products/1.json
    def update
      respond_to do |format|
        if @product.update(product_params)
          format.html { redirect_to @product, notice: 'Product was successfully updated.' }
          format.json { head :no_content }
        else
          format.html { render action: 'edit' }
          format.json { render json: @product.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # DELETE /products/1
    # DELETE /products/1.json
    def destroy
      @product.destroy
      respond_to do |format|
        format.html { redirect_to products_url }
        format.json { head :no_content }
      end
    end
  
    private
      # Use callbacks to share common setup or constraints between actions.
      def set_product
        @product = Product.find(params[:id])
      end
  
      # Never trust parameters from the scary internet, only allow the white list through.
      def product_params
        params.require(:product).permit(:title, :description, :image_url, :price)
      end
  end
  </code></pre>
  
  <p>ruby 2.0.0p353</p>
  
  <p>Rails 4.0.3</p>