My create method is not working and it used to work. Thanks in advance!
<%= form_for :category, url: categories_path do |f| %>
<p>
<%= f.label :title %><br>
<%= f.text_field :title %>
</p>
<p>
<%= f.submit %>
</p>
<% end %>
my controller:
class CategoriesController < ApplicationController
def show
@category = Category.where(id: params[:id]).first
end
def create
@category = Category.create(title: params[:category][:title])
redirect_to @category
end
end
Note: params[:category][:title] is in fact the correct value
my model:
class Category < ActiveRecord::Base
has_many :events
attr_accessor :title
end
my migration:
class CreateCategories < ActiveRecord::Migration
def change
create_table :categories do |t|
t.string :title
t.timestamps
end
end
end
And when I go to my form and input "main" (or anything else) in the text box and then click save It is saved in my database as:
id | title | created_a | updated_at |
---------------------------------------------------------
1 | NULL | 2013-11-16 21:30:59 | 2013-11-16 21:30:59 |
As you can see I am not being able to save my parameter in the database. This was not happening to me before, I went and tried to make some changes to my structure and this issue started happening so I reverted and now it does not even work even though I reverted. By the way I am using a mysql database. Thanks in advance!