http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes
On Tue, Feb 9, 2010 at 15:37, John Merlino
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> I hve a relationship like this in my model:
> Student
> has_one :student_fail
>
> StudentFail
> belongs_to :student_fail_state
> belongs_to :student
>
> StudentFailState
> has_many :students, :through => :student_fail
> has_many :student_fails
>
> In terms of the controller, what would be the best way to update
> attributes to the student_fails table?
>
> Here''s the view stuff:
>
> resources_form_helper.rb:
> def render_form_collection_field(form, name, label = nil, size = nil)
> render_form_field(form, name, label) do
> params = yield
> form.collection_select name, params[:collection],
> params[:value_method],params[:text_method], {}, {:size => size}
> end
> end
>
> def render_form_field(form, name, label=nil)
> label ||= name.to_s.gsub(/_id$/,
'''').gsub(''_'', '' '')
> label_class = "error" if error_fields.include?(name.to_sym)
> <<END_HTML
> <li>
> #{form.label name, label, :class => label_class}
> <div>#{yield}</div>
> </li>
> END_HTML
> end
> view:
> [ render_form_collection_field(f, :student_fail_state_id,
''level'') { {
> :collection => StudentFailState.true, :value_method => :id,
:text_method
> => :name} } ]
> #:student_fail_state_id doesn''t currently working because
it''s not in
> the student table.
>
> Any suggestions on how to update other tables from a dropdown menu?
> Thanks.
> --
> 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@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
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.