I am trying to understand what I am working with when I deal with
Rails forms_for and fields_for constructors.
Given  model has_many associations belongs_to dependency  and
          dependency has_many associations belongs_to model
>  @model = Model.find(:id)
and
>  forms_for @model do |f|
 what is ''f''?
>    f.fields_for :associations do |ff|
what is ''ff''?
How do I access dependencies on the named associations?
I have inspected these things and the volume of data that each
contains is such that I cannot post it here.  My difficulty is that I
cannot seem to get a handled
I will try to give an example:
forms_for @model do |f|
   f.fields-for :associations do |ff|
   ff.text-field :model_id
   ff.text_field :dependency_id:
   ff.dependency.some_attribute  # this display value simply does not
work.
   ff.collection_select(
                  :dependency_id, @dependencies, :id, :name,
                  { :prompt => ''Select a name'' },    
#options hash
                  { :class => :input_select,              #html hash
                    :id => :input_name,
                    :size => 1,
                    :title => I18n.t(''Enter a valid name''),
                    :value => ff.dependency_id }   # this does not
work either
                  )
Now, while I know that ff != dependency it does seem to me counter
intuitive that for each association of model I am unable to directly
address the dependency attributes from within the form constructor.
What is my fundamental misunderstanding with respect to forms_for and
fields_for and their treatment of DBMS rows?  How does one obtain a
dependent attribute for display purposes within a forms_for or
fields_for construct?
-- 
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 26, 9:20 am, byrnejb <byrn...-fqAF1SpE7daWxEb2tNKyrg@public.gmane.org> wrote:> > Now, while I know that ff != dependencyThis should be association rather than dependency. What I am asking is why, when ff acts in the place of a specific model.association, I cannot reach model.association.dependency.attribute. The problem domain requires that associations be created separately from either the model or the dependency but must be associated to an extant qualified row in each. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Jan-26  17:42 UTC
Re: Regarding form_for and fields-for content variable
James Byrne wrote:> I am trying to understand what I am working with when I deal with > Rails forms_for and fields_for constructors. > > Given model has_many associations belongs_to dependency and > dependency has_many associations belongs_to model > >> @model = Model.find(:id) > > and > >> forms_for @model do |f| > > what is ''f''?A FormBuilder. The documentation for form_for already tells you this. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
The most general it is a block value. For a from builder |f| is a form object with association parameters that have attributes that correspond to the object. f.text_field :name, :name is a db column or an attribute of the class. same as: array.each do |val| puts val end On Jan 26, 11:42 am, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> James Byrne wrote: > > I am trying to understand what I am working with when I deal with > > Rails forms_for and fields_for constructors. > > > Given model has_many associations belongs_to dependency and > > dependency has_many associations belongs_to model > > >> @model = Model.find(:id) > > > and > > >> forms_for @model do |f| > > > what is ''f''? > > A FormBuilder. The documentation for form_for already tells you this. > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.