Adding the owner association worked. Though it doesn't solve the problem of Hobo not catching the rollback, but I can get most of the way there by hiding things in the view. Thanks.
On Jul 20, 1:21 pm, oillio <[email protected]> wrote: > That is unfortunate. In the below article Tom states it should work > (though that was last > November):http://groups.google.com/group/hobousers/browse_thread/thread/68ccb37... > > The problem is, after I get this basic use_credit working I want to > expand it. The record is created from a code object. To know the > number of credits to use I need to query the code object. I was > planning on accessing it from the record object in before_create. > That won't exist yet in the permissions system. Is there a way to get > a pointer to the instantiating object in the permission system? Is > there another function maybe, something like > create_permitted_for_code? or something? > > Additionally, use_credit does modify the user object (deducts a > credit). I believe the permissions system is often queried to > determine if something can be done so side effects would be bad. Is > this correct? > > Anyway, thanks for the suggestion. An owner type association may work > out. I will try that first. > > On Jul 20, 11:56 am, kevinpfromnm <[email protected]> wrote: > > > I don't believe acting_user is available outside permission methods > > and those I suspect are getting the user passed to them sneakily. > > > You might want to try to hook that in on the permission method instead > > where you'd got the acting_user defined and hobo will understand a > > failure better. The only caveat would be to make sure your use credit > > method doesn't alter anything. Then add an after_create hook to do > > any alterations that might need to be done. > > > Alternative is to add an owner type association and use that for your > > call instead of acting_user. > > > On Jul 19, 6:33 pm, oillio <[email protected]> wrote: > > > > I am trying to use acting_user in before_create, but it doesn't seem > > > to exist. I recall reading on here that it should. Is that > > > incorrect? > > > > This is my code: > > > before_create { |record| acting_user.use_credit } > > > > Additionally, the use_credit function may return false (if the acting > > > user does not have any credits). In this case the creation should be > > > canceled (which works correctly). But Hobo doesn't get the message > > > and acts as if the record was created. Is there any way to send an > > > error message to Hobo at this point to indicate the creation failed? > > > > Thanks > > > -Dan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
