创建!丢弃财产

时间:2014-02-07 04:54:46

标签: ruby-on-rails activerecord

当我使用此代码时:

    @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
    })

未保存:meta参数。当我使用这段代码时:

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

{I} :meta参数按我的预期保存。这两个代码片段有什么区别?

编辑:门卫:AccessToken类由2个文件herehere定义。我没有看到任何会影响上述代码的内容。

1 个答案:

答案 0 :(得分:4)

您需要允许meta的{​​{1}}属性:

mass assignment