Joseph,

Whats the association between a quiz and a user. If they are related , then
you can write a callback in your quiz model

after_create :increase_user_xp
or
after_update :increase_user_xp


def increase_user_xp
  self.user.update(:xp => 50)
end


On Tue, Oct 7, 2014 at 6:44 AM, Joseph Wilks <[email protected]> wrote:

> So I'm creating a tv trivia game app, and when a user completes their
> quiz, I need to update certain aspects of the user (level/xp, also
> saving some of their answers to the database).
>
> However, I'm using devise for authentication, and I'm not sure how to
> access and update the current user when I'm in the quiz controller or
> quiz view. I'm assuming I need to add a helper method which gives the
> controller access to the current user, but I'm not sure how to do it
> exactly.
>
> Thanks in advance for your help.
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/409dc897c54b41e8c9f8e0f4610f909d%40ruby-forum.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAFKVRj_dWMSr-Kj3s1QCaCAd8h7dw5%2BwQbi3oNDqVJ80sYeHcQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to