Sure, current_user is set to the admin, but the context is the user
being banned, so the transition should still work.  After all most of
the time when people use lifecycles they are on objects other than
users, so current_user is obviously irrelevant then.

Bryan

On Sun, Mar 11, 2012 at 7:48 AM, Scorpio <[email protected]> wrote:
> My mistake on the save. Still I need some way to pass an ID of the
> user to be blocked because it's the admin that's doing the clicking :)
> ban wave incoming :)
>
> On Mar 11, 6:48 am, Bryan Larsen <[email protected]> wrote:
>> >        transition :block, { :inactive => :blocked }, :available_to
>> > => :all,
>> >                   :params => [:given_id]
>>
>> params should map to attributes or columns on your model.  Behind the
>> scenes Hobo will do something like user.given_id = params[:given_id].
>>  In this case I don't think you need any params as the model is
>> already found to get to the transition
>>
>>
>>
>> > to the users controller under admin
>>
>> >  def block(given_id)
>>
>> >    user = User.where(:id=>given_id)
>> >    user.state = 'blocked'
>> >    flash[:now] ="TEST"
>> >  end
>>
>> It's the do_block action you care about.   Block is the action that
>> renders the block form.   But Hobo should be creating a sufficient
>> block and do_block method for you, as long as you have auto_actions
>> :all or auto_actions :lifecycle in your controller.   You do have one
>> of those, don't you?
>>
>> You also aren't saving the user, so no changes are being persisted to
>> the database.
>>
>>  if you need to add code to your action you can do something like this:
>>
>> def do_block
>>   flash[:now] ="TEST"
>>   do_transition_action :block
>> end
>>
>> Bryan
>
> --
> 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.
>

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