J
John Griffiths
hi, i'm trying to work this out and been using a bit of the 'blog in 15
minutes' code to basically add a new item to a list from within the
'show' action of the list.
much like how when in the example blog app you view a post and can add
comments to it on the 'show' page.
here's the item model
class Item < ActiveRecord::Base
validates_presence_of :body
belongs_to :list
acts_as_list :scope => :list
end
and the list model
class List < ActiveRecord::Base
validates_presence_of :title
belongs_to :user
has_many :items, rder => "position"
end
and within the show list page i've got a 'add item' form
<% form_tag :action => "item", :id => @list do %>
<%= text_field "item", "body", 'size' => 15 %>
<%= submit_tag "Add" %>
<% end %>
that fires this action
def item
@item = List.find(params[:id]).items.create(params[:body])
flash[:notice] = "added your item."
redirect_to :action => "show", :id => params[:id]
end
it all works pretty well alas no item gets created, any ideas?
pulling my hair out on this one...
minutes' code to basically add a new item to a list from within the
'show' action of the list.
much like how when in the example blog app you view a post and can add
comments to it on the 'show' page.
here's the item model
class Item < ActiveRecord::Base
validates_presence_of :body
belongs_to :list
acts_as_list :scope => :list
end
and the list model
class List < ActiveRecord::Base
validates_presence_of :title
belongs_to :user
has_many :items, rder => "position"
end
and within the show list page i've got a 'add item' form
<% form_tag :action => "item", :id => @list do %>
<%= text_field "item", "body", 'size' => 15 %>
<%= submit_tag "Add" %>
<% end %>
that fires this action
def item
@item = List.find(params[:id]).items.create(params[:body])
flash[:notice] = "added your item."
redirect_to :action => "show", :id => params[:id]
end
it all works pretty well alas no item gets created, any ideas?
pulling my hair out on this one...