songkick/oauth2-provider — pull request #33 by pixeltrix (2012-07-27 07:37:09+00:00)
Title: Move authorization find/create for client to model

By defining the class method and calling it through the association
Active Record automatically assigns the owner so it's not needed in
grant_access!

By using attr_accessible :client it allows passing the client through
the attributes hash but prevents injected params assigning client_id.
The is_a? check is not strictly necessary as Active Record will blow
up when trying to assign a literal to a association, it's just there
to provide a more helpful error message.

It may be preferable to use create! rather than create in
find_or_create_for_client as no checking is done to see whether the
save was successful.