Ruby on Rails API - 创建数据库对象只返回空值的对象

时间:2017-06-29 22:15:13

标签: ruby-on-rails database api authentication rubygems

我有一个带有Knock for JWT Authentification的Ruby on Rails JSON API。

用户模型如下所示:

class User < ApplicationRecord

attr_accessor :email, :password, :password_digest
has_secure_password

end

迁移

class CreateUsers < ActiveRecord::Migration[5.1]
    def change
        create_table :users do |t|
            t.string :email
            t.string :password
            t.string :password_digest

            t.timestamps
        end
    end
end

还有一个带有脚手架CRUD-Methods的用户控制器。要生成JWT,我使用以下Controller,它继承自Knock :: AuthTokenController:

class UserTokenController < Knock::AuthTokenController
end

然而,当我用这样的控制台生成一个用户......

User.create(:email => 'test.test@test.com', :password => 'test', :password_digest => 'test')

...我得到一个空值的数据库对象: Console Output

1 个答案:

答案 0 :(得分:1)

由于您使用的是ERROR: Job failed (system failure): Error response from daemon: Mounts denied: The path /users/Shared/Sites/Werk/werk-mailer is not shared from OS X and is not known to Docker. You can configure shared paths from Docker -> Preferences... -> File Sharing. See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info. ,因此您不需要attr_accessor

删除此行

ActiveRecord