I am trying to create lists and each has 2 attributes name and description.Database does create it and save it when using console but not using the website form.When checking the log file I found that website form does not post instead uses gets and is redirected to itself, How do I make the website form POST instead of GET so it gets stored in database.
Log file:
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2013-09-18 12:35:14 -0400 Served asset /jquery_ujs.js - 304 Not Modified (0ms)
Here is list controller:
def create
@list = Lists.new(params[:lists])
if @list.save
redirect_to @list
else
render 'new'
end
end
def update
if @list.update_attributes(params[:lists])
flash[:success] = "lists updated"
redirect_to @list
else
render 'edit'
end
end
def new
@list = Lists.new
end
This is the form for users to create list
<%= form_for @list, url: newlist_path(@list), html: { method: :put } do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
</br>
<%= f.label :description %>
<%= f.text_field :description %>
<%= f.submit "Create the List" %>
<% end %>
raise params.to_yaml
in the first line of theupdate
method in the controller to see if it is really hitting theupdate
method. – Miguelgraz