Forum: Ruby on Rails undefined variable or method in form_tag url

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6c3acc025a63460a367b7981e606e032?d=identicon&s=25 Neubyr Neubyr (neubyr)
on 2009-03-08 09:27
Hello list,

In ref. to my previous post: http://www.ruby-forum.com/topic/180765

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
<h1>New <%= @is_subitem ? 'Subitem' : 'Item' %></h1>
<% 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.
This topic is locked and can not be replied to.