title: Ruby on Rails No Method Error in Controller, trying to create a record
body: <p>I've got a ruby on rails application and am trying to save category data to the system, but whenever I click save I get the error:</p>
  
  <pre><code>NoMethodError in CategoriesController#create
  undefined method `category' for #&lt;Category id: nil, genre: "", created_at: nil, updated_at: nil&gt;
  Extracted source (around line #29):
  
  27 def create
  28 @category = Category.new(category_params)
  29 if @category.save
  30 redirect_to @category, notice: 'Category was successfully created.'
  31 else
  32 render action: 'new'
  
  Rails.root: C:/Sites/week_15/New/my_bookshop_test2 _basic
  </code></pre>
  
  <p>This is my code in the categories_controller.rb:</p>
  
  <pre><code>class CategoriesController &lt; ApplicationController
     before_action :set_category, only: [:show, :edit, :update, :destroy]
     def new
       @category = Category.new
     end
     def create
       @category = Category.new(category_params)
       if @category.save
         redirect_to @category, notice: 'Category was successfully created.'
       else
         render action: 'new'
       end
     end
  </code></pre>
  
  <p>Can someone please help me.</p>