Hi Folks,
I want a form in a rails 3.0.10 app with form_for exactly I have 3 models
@apple, @basket, @table
class Apple belongs_to :tables belongs_to: baskets end
class Basket belongs_to :tables has_many :apples end
class Table has_many :baskets has_many :apples end
MY QUESTION
For apples I have many color as well as for baskets I have many different kinds of shapes
if I have the follow code in the index.html.erb file
<%= form_for :table do |f| %>
<%= f.collection_select(:basket, @basket, :id, :shape, {:prompt => true}) %>
<%= f.collection_select(:apple, @apple, :id, :color, {:prompt => true}) %>
<%= f.submit %>
<% end %>
*** appear the page correctly ***
meanwhile if I have the follow code
<%= form_for @table do |f| %>
<%= f.collection_select(:basket, @basket, :id, :shape, {:prompt => true}) %>
<%= f.collection_select(:apple, @apple, :id, :color, {:prompt => true}) %>
<%= f.submit %>
<% end %>
the page show the follow error page
//////////// undefined method `model_name' for NilClass:Class
Extracted source (around line #1):
1: <%= form_for @table do |f| ////////////
change only the first line in the example I have <%= form_for @table do
f> %> and not
<%= form_for :table do |f| %>
NOW
which is the different between
<%= form_for @table do |f| %>
and
<%= form_for :table do |f| %>
sorry for this post but I want to understand the Rails philosophy
thanks a lot anyway,
C