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
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).
Thanks,
donz
On Mar 12, 4:14 pm, Matt Jones <[email protected]> wrote:
> acting_user is *only* available on model objects, and even then only
> typically within the context of a save/update transaction or in a
> permission check.
>
> current_user is the one to use in view/controller code.
>
> --Matt Jones
>
> On Mar 12, 2010, at 3:10 PM, Owen Dall wrote:
>
> > While we are on the subject, in which context is "self.acting_user"
> > available?
>
> > For example, so we can build a tag to display the user...
>
> > On Fri, Mar 12, 2010 at 2:45 PM, kevinpfromnm
> > <[email protected]> wrote:
> > well, there's no real choice in the model, you only have acting_user.
> > the point I was making is there is rarely a case where the model
> > acting_user is not the same User as the controller current_user, since
> > most time you're checking acting_user it was current_user passed
> > behind the scenes from controller/view to the model.
>
> > On Mar 12, 11:54 am, Owen <[email protected]> wrote:
> > > Thanks, I think most folks will use "acting_user"
>
> > > On Mar 12, 1:46 pm, kevinpfromnm <[email protected]> wrote:
>
> > > > probably the bigger confusion is there's very few cases where the
> > > > acting_user isn't going to be the current_user. maybe in some
> > special
> > > > multipart lifecycle actions but I can't think of any other case
> > that I
> > > > might use a different acting_user.
>
> > > > On Mar 12, 7:52 am, Owen <[email protected]> wrote:
>
> > > > > Think this needs another discussion for all new to Hobo:
>
> > > > > Here is a post from Tom a while back:
>
> > > > > Although it is a common source of confusion, it's actually
> > fairly
> > > > > important to understand the difference between the two
> > concepts, or
> > > > > you're at risk of messing up your nice MVC separation.
> > current_user
> > > > > only makes sense in conjunction with the idea of a "current
> > > > > session",
> > > > > which only exists in the view and controller layers. That's
> > why in
> > > > > 'normal' Rails apps you just can't get at that information
> > from the
> > > > > model.
>
> > > > > But it struck me that "this model-level action is happening on
> > > > > behalf
> > > > > some specific user" is such a fundamental aspect of the kind
> > of apps
> > > > > we right, that it was a good idea to support this in the model
> > > > > layer.
>
> > > > > As Bryan says, it's not _necessarily_ the current_user from the
> > > > > session. Rather, it's the user who is performing this action -
> > the
> > > > > acting_user.
>
> > > > > Sometimes a common source of confusion is a good thing, because
> > > > > what's
> > > > > actually going on is a common misconception, and the confusion
> > is an
> > > > > opportunity to straighten things out.
>
> > > > > Tom
>
> > --
> > 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
> > athttp://groups.google.com/group/hobousers?hl=en
> > .
>
> > --
> > Thanks,
> > - Owen
>
> > --
> > 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
> > athttp://groups.google.com/group/hobousers?hl=en
> > .
--
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.