Reputation: 32730
When I use this code:
@access_token = Doorkeeper::AccessToken.create!({
:application_id => grant.application_id,
:resource_owner_id => grant.resource_owner_id,
:scopes => grant.scopes_string,
:expires_in => server.access_token_expires_in,
:use_refresh_token => server.refresh_token_enabled?,
:meta => grant.meta
})
The :meta
parameter is not saved. When I use this code:
@access_token = Doorkeeper::AccessToken.new({
:application_id => grant.application_id,
:resource_owner_id => grant.resource_owner_id,
:scopes => grant.scopes_string,
:expires_in => server.access_token_expires_in,
:use_refresh_token => server.refresh_token_enabled?
})
@access_token.meta = grant.meta
@access_token.save!
The :meta
parameter is saved as I expected. What is the difference between these two code snippets?
Edit: the Doorkeeper:AccessToken class is defined in 2 files, here and here. I don't see anything that would impact the above code though.
Upvotes: 0
Views: 48
Reputation: 38645
You need to allow meta
attribute for mass assignment
:
if ::Rails.version.to_i < 4 || defined?(ProtectedAttributes)
attr_accessible :resource_owner_id,
:application_id,
:expires_in,
:redirect_uri,
:scopes,
:meta # Add this
end
Upvotes: 4