Hi Leuddens
This is a tricky and lengthy one that''s about to blow my current
project
to little glittering pieces ;-)
I''m using select multiple in a subform (as described in Ryan''s
excellent
Complex Forms screencasts on railscasts.com. This is the relation:
Offer has_and_belongs_to_many :parts
Part has_many :manufacturers
The Offer form allows you to add/remove parts. And the _part.html.erb
partial contains one text_input "name" and one select-multiple
"manufacturer_ids".
The object (form element) names in the _part partial are correctly named
"offer[part_attributes][]" and the select multiple adds
"[manufacturer_ids][]" to it, which results in the nice to look at...
offer[part_attributes][][manufacturer_ids][]
I create two parts and select two manufacturers for each part, hit
submit and take a look at the params hash:
[
{"manufacturer_ids"=>[], "name"=>"FIRST
PART"},
{"manufacturer_ids"=>[]},
{"manufacturer_ids"=>[], "name"=>"SECOND
PART"},
{"manufacturer_ids"=>[]},
{"manufacturer_ids"=>[]},
{"manufacturer_ids"=>[]}
]
That doesn''t look too good. Apparently, the form parameters are not
parsed correctly into the params hash at all.
After some research, I found the follwing patch:
http://dev.rubyonrails.org/ticket/10101
Once applied, the output looks slightly better:
params[:offer][:part_attributes] =>
[
{"manufacturer_ids"=>["209"],
"name"=>"FIRST PART"},
{"manufacturer_ids"=>["254"],
"name"=>"SECOND PART"},
{"manufacturer_ids"=>["238"]},
{"manufacturer_ids"=>["209"]},
{"manufacturer_ids"=>["254"]},
{"manufacturer_ids"=>["238"]}
]
But this is still not what ActiveRecord needs in order to write the
records correctly. Even worse: The nesting (which manufacturer_ids
belong to which part) are lost, so I can''t even tweak the params hash
manually in the controller.
I can''t believe that I''m the only one facing this issue. As a
matter of
fact, if you decide to have a another complex form within yet a complex
form partial, you will face the same challenge.
Unfortunately, the UrlEncodedPairParser - that seems responsible for
this - is too magic for my skills.
Please help, somebody, I''m really stuck knee deep with this one.
Many thanks! -sven
PS:
Could Ruby 1.8''s Array handling (random member order) have anything to
do with this? If so, Ruby 1.9 might help as it maintains Array member
order - unfortunately, I have no install of Ruby 1.9 at hand to verify
this.
--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On Dec 25, 3:21 pm, Sven Schwyn <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Could Ruby 1.8''s Array handling (random member order) have anything to > do with this? If so, Ruby 1.9 might help as it maintains Array member > order - unfortunately, I have no install of Ruby 1.9 at hand to verify > this.Rails isn''t yet comptatible with Ruby 1.9, in my understanding. ///ark --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Mark Wilden wrote:> On Dec 25, 3:21�pm, Sven Schwyn <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > >> Could Ruby 1.8''s Array handling (random member order) have anything to >> do with this? If so, Ruby 1.9 might help as it maintains Array member >> order - unfortunately, I have no install of Ruby 1.9 at hand to verify >> this. > > Rails isn''t yet comptatible with Ruby 1.9, in my understanding. > > ///arkis ruby 1.9 out yet? -- 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
On Dec 25, 8:14 pm, Xk Lin <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> is ruby 1.9 out yet?It was released today (Christmas Day). http://www.ruby-lang.org/en/news/ However, it is a development release only, so it may not be completely stable. The know stable version is on the download page and is 1.8.6- p111. -- Travis --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 25, 6:50 pm, Mark Wilden <m...-OCn100epQuBBDgjK7y7TUQ@public.gmane.org> wrote:> Rails isn''t yet comptatible with Ruby 1.9, in my understanding.Ruby 1.9 on Rails 2.0 tests correctly for me. However, Ruby 1.9 on Rails 1.2 may not. Also, remember that the Ruby 1.9, released today, is still a development release, so not everything may be working properly with the Ruby interpreter. -- Travis --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 25, 9:16 pm, tekwiz <twarl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Ruby 1.9 on Rails 2.0 tests correctly for me. However, Ruby 1.9 on > Rails 1.2 may not.I got my information from http://blog.codefront.net/2007/12/26/ruby-190-has-been-released/ ///ark --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
tekwiz wrote:> On Dec 25, 6:50 pm, Mark Wilden <m...-OCn100epQuBBDgjK7y7TUQ@public.gmane.org> wrote: >> Rails isn''t yet comptatible with Ruby 1.9, in my understanding. > > Ruby 1.9 on Rails 2.0 tests correctly for me. However, Ruby 1.9 on > Rails 1.2 may not. > > Also, remember that the Ruby 1.9, released today, is still a > development release, so not everything may be working properly with > the Ruby interpreter. > > -- > TravisI''ll give Ruby 1.9 a try as soon as I can. But I''m not even sure whether it will have an influence on this issue. It would be great to get in touch with someone who knows a little something about how Rails parses the request into the params hash. Big thanks!! -sven -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Dec-26 23:03 UTC
Re: Complex Forms Misbehavior (possibly a Rails bug)
On 26 Dec 2007, at 05:16, tekwiz wrote:> > On Dec 25, 6:50 pm, Mark Wilden <m...-OCn100epQuBBDgjK7y7TUQ@public.gmane.org> wrote: >> Rails isn''t yet comptatible with Ruby 1.9, in my understanding. > > Ruby 1.9 on Rails 2.0 tests correctly for me. However, Ruby 1.9 on > Rails 1.2 may not. >Have you actually run the rails unit tests? There are still many failing tests on 1.9 Fred> Also, remember that the Ruby 1.9, released today, is still a > development release, so not everything may be working properly with > the Ruby interpreter. > > -- > Travis > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---