I created a small form with two fields and in the future intend to expand this form with one or two fields. It turns out that the inclusion of the data in sqlite this not being done, but gives no error.
The application is being developed to be a to-do list.
Can you tell me the possible reasons?
I have a model:
class ToDoList < ActiveRecord::Base
attr_accessible :is_favorite, :name, :description
has_many :tasks, dependent: :destroy
belongs_to :member
end
and 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
views: new.html.erb
<h2> add new task</h2>
<%= render partial: 'to_do_list' %>
_to_do_list.httml.erb:
<%= form_for(@todo_list = ToDoList.new) do |f| %>
<%#= form_for(@todo_list) do |f| %>
<% if @todo_list.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@todo_list.errors.count, "error") %> prohibited this todo_list from being saved:</h2>
<ul>
<% @todo_list.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :description %><br />
<%= f.text_area :description %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>