Hi Craig, I have reproduced your problem with the latest Hobo, and you are completely right: creating a new manufacturer in a new manufacturer_part form AND inside an existing record (show of partnumber) was making Hobo partial system crazy (the part contexts were invalid, and so the Ajax request failed).
I have tested your solution with the Hobo integration tests and everything seems OK. Those tests use partials a lot so I'm pretty confident we are not breaking anything. I've opened a pull request in case anyone else want to comment on the code: https://github.com/Hobo/hobo/pull/37. This will apply to future versions of Hobo, please say if you think it's important to backport this to Hobo 1.3 or you can manage patching the gem. Good job debugging the problem! Warm regards, Ignacio El 04/09/13 22:03, Craig DeHaan escribió: > > Hello, > > I am using Hobo 1.3 and just added the jquery plugin because I wanted to > use the <select-one-or-new> tag. I am currently using it in two places. > In the first case it is working as intended, but the second case is a > little more complicated. I will try to explain how it is used in both cases. > > Models: > > PartNumber > number :string > has_many :manufacturer_parts > belongs_to :footprint > end > > > Footprint > name :string > has_many :part_numbers > end > > > ManufacturerParts > number :string > belongs_to :part_number > belongs_to :manufacturer > end > > > Manufacturer > name :string > has_many :manufacturer_parts > end > > > In the first (simpler) case, I am creating a new PartNumber. I use the > <select-one-or-new> to select the footprint, or create a new one. That > works. > > In the second case I am on a PartNumber's show page. On this page is a > collection of ManufacturerParts. Because I have defined > create_for_part_number in the ManufacturerPartsController I have a form > here to add a new ManufacturerPart to the collection. Within that form I > use a <select-one-or-new> to select the Manufacturer. When creating a > new manufacturer I get the following error: ArgumentError (invalid > typed-id: :manufacturer). I think I have traced the problem down to the > following code in Dryml::TemplateEnvironment#typed_id: > > id = if (typed_id = object.try.typed_id) > typed_id > elsif object == @this > "this" > end > > Notice that there is a case where id does not get assigned a value: > object does not return a valid typed_id and object is not @this. In my > first use case typed_id returns "this:footprint". I believe that in the > second case @this is the PartNumber and object is the new > ManufacturerPart and therefore the if statement does not assign anything > to id and so typed_id returns ":manufacturer", which is invalid. As a > test I tried to modify the code to the following just to make sure > typed_id always returns something that is valid: > > id = if (typed_id = object.try.typed_id) > typed_id > else > "this" > end > > > Interestingly this worked, and as far as I know it didn't break anything > else. Which brings me to the question. Is this likely to break > something? It doesn't seem like this is the right way to fix the > problem, but I do not know enough about Hobo's internals to come up with > a better solution. Any suggestions? > > FYI - I did a quick check and it looks like Hobo 2.0.1 uses the same > code for typed_id > > > > -- > You received this message because you are subscribed to the Google > Groups "Hobo Users" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/hobousers. > For more options, visit https://groups.google.com/groups/opt_out. -- Ignacio Huerta Arteche http://www.ihuerta.net Teléfono: 0034 645 70 77 35 Email realizado con software libre -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/hobousers. For more options, visit https://groups.google.com/groups/opt_out.
