Ah yes, owner_id is not on Tracking. I have not been doing migrations b/c I was worried about breaking my pre-existing database. I guess I'll rename the existing user_id column to owner_id and see what happens.
Thanks for the offer of off-list conversion help. I'll take you up on that if I get stuck. Thanks Matt, Mike On Mar 1, 12:06 pm, Matt Jones <[email protected]> wrote: > On Feb 28, 2010, at 10:15 PM, Michael wrote: > > > > > I'm revamping an app that I wrote back in 2007 with Hobo 0.6.2. The > > books have been a HUGE help in that respect so thanks to all who > > contributed. > > > I'm trying to get ownership working in my app so that I can make use > > of owner_changed? and owner_is? for permissions. I'm doing something > > very similar to what's in the Agility tutorial. In my app a user has > > many trackings a tracking belongs to a user. So here's what I have: > > > In user.rb -- has_many :trackings, :class_name => > > "Tracking", :foreign_key => "owner_id" > > > in tracking.rb -- belongs_to :owner, :class_name => "User", :creator > > => true > > > The trouble kicks in when I try to show a user's trackings. In my > > user controller I have this: > > > def show_trackings > > > �...@this = Tracking.paginate(:page => params[:page], > > :conditions => [ "user_id = ?", > > params[:id].to_i ], > > :order => "term ASC", > > :include => [:interest, :user]) > > end > > > When I run it I get this error: "Association named 'user' was not > > found; perhaps you misspelled it? > > ". If I remove user from the "include" the page loads fine. But if I > > continue on from the show trackings page and try to add a new tracking > > I then get an error that says "unknown attribute: owner_id" when I try > > to save a newly created tracking. I guess I'm missing something. > > Is owner_id actually a field on Tracking? The conditions above seem to > imply that it's not. You'll need to get the various associations lined > up properly. > > > While I'm asking this I have another question about how I'm doing the > > show_trackings method. When I had this app working in the old Hobo > > instead of doing a paginate I just used this - > > hobo_show_collection :trackings, :order => "term ASC", :include => > > [:interest, :user] -- Is there something similar in the current Hobo? > > Should I be using hobo_index_for ? > > Yep - index_for and friends do essentially the same thing as the old > hobo_show_collection. > > Feel free to bug me off-list if you run into any other problems - > upgrading from pre-0.8 versions can get rough, and there's terribly > little documentation that far back. > > --Matt Jones -- 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.
