On Mar 15, 2010, at 5:25 PM, donz wrote:

I am trying to implement a very common pattern - (almost) all data are
owned by a particular user and no other users should be able to see/
change it.  The normal way I would do this in rails is to set the
user_id in the owned data model before creating the record - which is
what I think this thread is discussing.

Using Hobo 1.0, I tried a very simple example of this, two tables
Users and LogEntries.  in the log_entry model I tried to access
acting_user in various ways and all I get is "you dummy, you are
trying to access nil.id .....".  puts "#{acting_user}" >> nil

Right - acting_user is only set on the model during a create or a save; it's available in the various validation methods, permission methods and callbacks, but not typically set outside that context.

Since I am new to hobo, and this list, let me ask some dumb
questions.  Is this the right list for asking these kind of questions
(I hit the bug list first and got a rocket in reply)?  Since I can't
access acting_user in the model, should I presume that this discussion
is preliminary to making it available?  Is there some other example of
this design pattern?  (I have looked in the various manuals/examples
and not found the a starting place).

Heh - this may be a case of there not being enough "there" there to merit much documentation. The use case you're describing is indeed common, common enough that it's been absorbed as a model extension:

http://cookbook.hobocentral.net/manual/model#creator

Hope this helps!

--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.

Reply via email to