Hello Craig, your solution is very interesting. We are going to try to reproduce the problem at the weekend and then we will give you a response.
At the moment, you can try to pass the Hobo integration tests with your code and see if it works. Thanks, Regards, Imanol El miércoles, 4 de septiembre de 2013 22:03:31 UTC+2, 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.
