Hi,

I'm toying with Hobo to see if it might not just be what I've been looking for. 
So far I like what I'm seeing, but in going through the tutorials (for Rails 3) 
I tripped over something that took me a little while to figure out.

I was doing Tutorial 8, the one that introduces many-to-many relationships with 
recipes and categories. Since in order to get the feel for a framework I like 
to type the code myself rather than paste it, I had a CategoryAssignment that 
looked like this:

class CategoryAssignment < ActiveRecord::Base
  hobo_model # Don't put anything above this
  fields do
    timestamps
  end

  belongs_to :recipe
  belongs_to :category
#...
end

With that, only one of Recipe or Category could have a children view hint. If I 
added children to both, it would all blow up complaining that nil doesn't have 
a class_name method. I started adding trace code through Hobo (pre26) in the 
hope that I'd see something show up but the issue remained mysterious. Archives 
seemed to indicate that similar problems had been solved around pre22.

In despair I went through the example code line by line and discovered that it 
had those belongs_to lines in the other order:

  belongs_to :category
  belongs_to :recipe

I flipped those and all of a sudden everything works.

Now this may be something that's familiar to some (I have only limited 
experience with Rails) but it certainly came as a shock to me! You'd think that 
the order of belongs_to shouldn't matter, instead it seems to have to be 
alphabetical. I searched for this but I couldn't find any indication beyond the 
fact that order matters when guessing join tables (in has_and_belongs_to_many), 
but that seems unrelated.

So this seems like it could be a bug. If not, it should be noted in the 
tutorial in case someone else trips up on the same issue.

Thanks!

-- 
Robin Berjon
  Robineko (http://robineko.com/)



-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to