1
Good night, you guys!
I created a small form with two fields and in the future I intend to expand this form with one or two more fields. It happens that the insertion of the data in the sqlite is not being done, but does not give any error.
The application is being developed to be a to-do list.
Can you please tell me possible reasons?
well, I have as a model:
class ToDoList < ActiveRecord::Base
attr_accessible :is_favorite, :name, :description
has_many :tasks, dependent: :destroy
belongs_to :member
end
and as a controller:
class ToDoListsController < ApplicationController
...
def new
@todo_list = ToDoList.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @todo_list }
end
end
...
def create
@todo_list = ToDoList.new(params[:todo_list])
respond_to do |format|
if @todo_list.save
format.html { redirect_to @todo_list, notice: 'Todo list was successfully created.' }
format.json { render json: @todo_list, status: :created, location: @todo_list }
else
format.html { render action: "new" }
format.json { render json: @todo_list.errors, status: :unprocessable_entity }
end
end
end
end
Thank you in advance!
Edit
I noticed that I was calling the wrong params, calling it @todo_list and it was @to_do_list. It serves as an example of the lack of attention!
You’ve been watching me, folks.
What is the content of the create method in your Todolistscontroler class? This is the method where the object is saved in the database.
– Bernardo Botelho
I forgot to create it, I will edit rs. create is:
def create
 @todo_list = ToDoList.new(params[:todo_list])

 respond_to do |format|
 if @todo_list.save
 format.html { redirect_to @todo_list, notice: 'Todo list was successfully created.' }
 format.json { render json: @todo_list, status: :created, location: @todo_list }
 else
 format.html { render action: "new" }
 format.json { render json: @todo_list.errors, status: :unprocessable_entity }
 end
 end
 end
– noob-rails