Hello list,
In ref. to my previous post: RESTful nested resources and polymorphism? - Rails - Ruby-Forum
I am getting “undefined local variable or method `item_path’ for
#ActionView::Base:0xb7065650”, when I try to create a new item.
Following is the code in my new.rhtml
New <%= @is_subitem ? 'Subitem' : 'Item' %>
<% form_tag :item, :url => item_path do %> <%= render :partial => 'item_form' %> <%= submit_tag "Create" %> <% end %>The new and create actions are as follows:
def new
@item = Item.new
end
def create
@item = Item.new(params[:items])
@topic = Topic.find(params[:topic_id])
@item.topic = @topic
@item.position = @topic.items.size
respond_to do |format|
if @item.save
flash[:notice] = “Item was successfully created.”
format.html { redirect_to item_url(@item.topic,@item) }
format.xml { head :created, :location =>item_url(@item.topic,
@item) }
else
format.html { render :action => “new” }
format.xml { render :xml => @item.errors.to_xml }
end
end
end
Where is the problem? Any clues?
Also any help on RESTful nested resources and self-referential
associations?
Thanks,
CS.