1

私のクラスとマイグレーションは以下の通りです。私が誤ってやっていることは、私が間違った関連付けを設定したかどうか、または私が期待しているレコードを返すための正しい属性/メソッドを使用していないかどうかはわかりません。たとえば、accountのすべてのメンバー(super_admin_usersadmin_usersおよびstandard_users)のリストを取得するにはどうすればよいですか? Railsのコンソールでは、私はAccounts::Account.first.users_account_membersをしようと、私は次を得る:Rails has_manyから名前空間付きモデルを使用したポリモーフィック

2.4.0 :003 > Accounts::Account.first.users_account_members 
Accounts::Account Load (0.6ms) SELECT "accounts_accounts".* FROM "accounts_accounts" ORDER BY "accounts_accounts"."id" ASC LIMIT $1 [["LIMIT", 1]] 
NoMethodError: undefined method `users_account_members' for #<Accounts::Account:0x007fcb10cce7b8> 

と私はAccounts::Account.first.users_super_admin_usersをしようと、私は次を得る:

2.4.0 :004 > Accounts::Account.first.users_super_admin_users 
Accounts::Account Load (0.6ms) SELECT "accounts_accounts".* FROM "accounts_accounts" ORDER BY "accounts_accounts"."id" ASC LIMIT $1 [["LIMIT", 1]] 
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column accounts_account_memberships.accounts_account_type does not exist 

accounts_account_memberships.accounts_account_typeを探すことにより、それがいるようですユーザ側だけがアソシエーションのaccounts_accountが多形であるかのように振る舞います。

はまた、どのように、逆に、私はのメンバーであるすべてのaccounts特定super_admin_user(またはadmin_user、またはstandard_user)のリストを得るのですか?

アプリ/モデル/アカウント/ account.rb

module Accounts 
    class Account < ActiveRecord::Base 

    self.table_name = 'accounts_accounts' 

    belongs_to :users_account_owner, class_name: 'Users::SuperAdminUser', inverse_of: :accounts_owned_accounts 
    accepts_nested_attributes_for :users_account_owner 

    has_many :accounts_account_memberships, class_name: 'Accounts::AccountMembership', as: :accounts_account, dependent: :destroy 
    has_many :users_super_admin_users, through: :accounts_account_memberships, source: :users_account_member, source_type: 'Users::SuperAdminUser' 
    has_many :users_admin_users,  through: :accounts_account_memberships, source: :users_account_member, source_type: 'Users::AdminUser' 
    has_many :users_standard_users, through: :accounts_account_memberships, source: :users_account_member, source_type: 'Users::StandardUser' 

    end 
end 

アプリ/モデル/ユーザー/ super_admin_user.rb

:ここ

は団体と私のクラスとその移行しています

module Users 
    class SuperAdminUser < ApplicationRecord 

    self.table_name = 'users_super_admin_users' 

    has_many :accounts_owned_accounts, class_name: 'Accounts::Account', inverse_of: :users_account_owner, foreign_key: :users_account_owner_id 

    has_many :accounts_account_memberships, class_name: 'Accounts::AccountMembership', as: :users_account_member, dependent: :destroy 
    has_many :accounts_accounts, through: :accounts_account_memberships, source: 'Accounts::Account' 

    end 
end 

app/models/users/admin_user.rb

module Users 
    class AdminUser < ApplicationRecord 

    self.table_name = 'users_admin_users' 

    has_many :accounts_account_memberships, class_name: 'Accounts::AccountMembership', as: :users_account_member, dependent: :destroy 
    has_many :accounts_accounts, through: :accounts_account_memberships, source: 'Accounts::Account' 

    end 
end 

アプリ/モデル/ユーザー/ standard_user.rb

module Users 
    class StandardUser < ApplicationRecord 

    self.table_name = 'users_standard_users' 

    has_many :accounts_account_memberships, class_name: 'Accounts::AccountMembership', as: :users_account_member, dependent: :destroy 
    has_many :accounts_accounts, through: :accounts_account_memberships, source: 'Accounts::Account' 

    end 
end 

アプリ/モデル/アカウント/ account_membership.rb

module Accounts 
    class AccountMembership < ActiveRecord::Base 

    self.table_name = 'accounts_account_memberships' 

    belongs_to :accounts_account, class_name: 'Accounts::Account', inverse_of: :accounts_account_memberships 
    belongs_to :users_account_member, polymorphic: true 

    end 
end 

デシベル/移行/ 20170203001000_create_users_super_admin_user .rb

class CreateUsersSuperAdminUser < ActiveRecord::Migration[5.0] 
    def change 
    create_table :users_super_admin_users do |t| 

     t.string :email, index: { unique: true } 
     t.string :first_name 
     t.string :last_name 
     t.string :username, index: { unique: true } 

     t.timestamps null: false 

    end 
    end 
end 

DB /移行/ 20170203001100_create_users_admin_user.rb

class CreateUsersAdminUser < ActiveRecord::Migration[5.0] 
    def change 
    create_table :users_admin_users do |t| 

     t.string :email, index: { unique: true } 
     t.string :first_name 
     t.string :last_name 
     t.string :username, index: { unique: true } 

     t.timestamps null: false 

    end 
    end 
end 

DB /移行/ 20170203001200_create_users_standard_user.rb

class CreateUsersStandardUser < ActiveRecord::Migration[5.0] 
    def change 
    create_table :users_standard_users do |t| 

     t.string :email, index: { unique: true } 
     t.string :first_name 
     t.string :last_name 
     t.string :username, index: { unique: true } 

     t.timestamps null: false 

    end 
    end 
end 

DB /移行/ 20170204001000_create_accounts_account。RB

class CreateAccountsAccount < ActiveRecord::Migration[5.0] 
    def change 
    create_table :accounts_accounts do |t| 

     t.string :name, index: { unique: true } 

     t.references :users_account_owner, index: true, foreign_key: { to_table: :users_super_admin_users } 

     t.timestamps null: false 

    end 
    end 
end 

デシベル/あなたがAccountMembershipモデルにおける型の列を宣言する必要があり、そのようなポリモーフィック団体と連携するために/ 20170204001100_create_accounts_account_membership.rb

class CreateAccountsAccountMembership < ActiveRecord::Migration[5.0] 
    def change 
    create_table :accounts_account_memberships do |t| 

     t.references :accounts_account, index: { name: 'index_accts_acct_mbrships_on_accts_acct_id' } 
     t.references :users_account_member, polymorphic: true, index: { name: 'index_accts_acct_mbrships_on_users_acct_member_type_and_id' } 

     t.timestamps null: false 

    end 
    end 
end 

答えて

0

を移行します。このよう

class AddAccountsAccountTypeToAccountsAccountMemberships < ActiveRecord::Migration[5.0] 
    def change 
    add_column :accounts_account_memberships, :accounts_account_type, :string 
    end 
end 

私はあなたの代わりにAccounts::Account.first.users_account_members

Accounts::Account.first.accounts_account_membershipsを使用すると、すべてのaccounts特定のリストを取得する必要があり、すべてのメンバーのリストを取得するには、正しくあなたを理解していればstandard_userUsers::StandardUser.first.accounts_accounts

+0

迅速な対応をありがとう。提案した列を追加して少し進歩しました。つまり、accounts_account_typeに関するエラーは表示されなくなりましたが、まだレコードを返さないままでした。アソシエーションのaccounts_account側が多相ではないため、accounts_account_typeがどのように必要であったかもわかりませんでした。私の問題は、モデルが名前空間内にあることと関係していたと考えられており、問題が発生しているように見えます。私の解決策を見てください。私の解決策は、現在期待どおりに機能しているようです。 – eggroll

0

このように、この関連の複雑さは私の名前空間の使用であり、その解決策は次のように見えます。比較的単純です - 主にアソシエーションのaccounts_account側にforeign_key:オプションが追加されています。

Iは、出発点として、このソースを使用する:ユーザタイプ(Users::SuperAdminUserUsers::AdminUser、及びUsers::StandardUser)、TagAccounts::AccountAccounts::AccountMembershipに適合TagTargetに適応のそれぞれに適合Articleと、http://joeswann.co.nz/rails-4-has_many-polymorphic-relationships。私はその後、クラスの名前空間を収容するために必要な場所にclass_name:foreign_key:オプションを追加しました。

さらに、インスタンスメソッドusers_account_membersAccounts::Accountクラスに追加して、すべてのユーザータイプのアカウントメンバーを取得できるようにしました。私はこのメソッドの追加なしですべてのユーザータイプのアカウントメンバーのすべてを取得できない場合は、のような多相関係のポイント/メリットが何であるか疑問に思っています。 Accounts::Accountとそれぞれのユーザータイプとの間で別々のhas_manyの関係で同じことを達成できるようです。

改定クラス

は、次のように(何の移行への変更はなかった)を見て:これらの変更により

module Accounts 
    class Account < ApplicationRecord 
    has_many :accounts_account_memberships, class_name: 'Accounts::AccountMembership', dependent: :destroy, foreign_key: :accounts_account_id 
    has_many :users_super_admin_users, through: :accounts_account_memberships, source: :users_account_member, source_type: "Users::SuperAdminUser" 
    has_many :users_admin_users,  through: :accounts_account_memberships, source: :users_account_member, source_type: "Users::AdminUser" 
    has_many :users_standard_users, through: :accounts_account_memberships, source: :users_account_member, source_type: "Users::StandardUser" 

    def users_account_members 
     self.users_super_admin_users + self.users_admin_users + self.users_standard_users 
    end 
    end 
end 

module Accounts 
    class AccountMembership < ApplicationRecord 
    belongs_to :accounts_account, class_name: 'Accounts::Account' 
    belongs_to :users_account_member, polymorphic: true 
    end 
end 

module Users 
    class SuperAdminUser < ApplicationRecord 
    has_many :accounts_account_memberships, class_name: 'Accounts::AccountMembership', as: :users_account_member, dependent: :destroy 
    has_many :accounts_accounts, through: :accounts_account_memberships, as: :users_account_member 
    end 
end 

module Users 
    class AdminUser < ApplicationRecord 
    has_many :accounts_account_memberships, class_name: 'Accounts::AccountMembership', as: :users_account_member, dependent: :destroy 
    has_many :accounts_accounts, through: :accounts_account_memberships, as: :users_account_member 
    end 
end 

module Users 
    class StandardUser < ApplicationRecord 
    has_many :accounts_account_memberships, class_name: 'Accounts::AccountMembership', as: :users_account_member, dependent: :destroy 
    has_many :accounts_accounts, through: :accounts_account_memberships, as: :users_account_member 
    end 
end 

、Railsのコンソールで応答なりました(注:データベースのシード・ファイルは、コンソール出力の下に表示されます) :

2.4.0 :001 > Accounts::Account.first.users_account_owner 
Accounts::Account Load (0.8ms) SELECT "accounts_accounts".* FROM "accounts_accounts" ORDER BY "accounts_accounts"."id" ASC LIMIT $1 [["LIMIT", 1]] 
Users::SuperAdminUser Load (0.5ms) SELECT "users_super_admin_users".* FROM "users_super_admin_users" WHERE "users_super_admin_users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]] 
=> #<Users::SuperAdminUser id: 1, email: "[email protected]", first_name: "Gregory", last_name: "Arnold", username: "garnold0", created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57"> 

    2.4.0 :002 > Users::SuperAdminUser.first.accounts_owned_accounts 
Users::SuperAdminUser Load (0.4ms) SELECT "users_super_admin_users".* FROM "users_super_admin_users" ORDER BY "users_super_admin_users"."id" ASC LIMIT $1 [["LIMIT", 1]] 
Accounts::Account Load (0.4ms) SELECT "accounts_accounts".* FROM "accounts_accounts" WHERE "accounts_accounts"."users_account_owner_id" = $1 [["users_account_owner_id", 1]] 
=> #<ActiveRecord::Associations::CollectionProxy [#<Accounts::Account id: 1, name: "Ooba", users_account_owner_id: 1, created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">]> 

    2.4.0 :003 > Accounts::Account.first.users_super_admin_users 
Accounts::Account Load (0.6ms) SELECT "accounts_accounts".* FROM "accounts_accounts" ORDER BY "accounts_accounts"."id" ASC LIMIT $1 [["LIMIT", 1]] 
Users::SuperAdminUser Load (0.8ms) SELECT "users_super_admin_users".* FROM "users_super_admin_users" INNER JOIN "accounts_account_memberships" ON "users_super_admin_users"."id" = "accounts_account_memberships"."users_account_member_id" WHERE "accounts_account_memberships"."accounts_account_id" = $1 AND "accounts_account_memberships"."users_account_member_type" = $2 [["accounts_account_id", 1], ["users_account_member_type", "Users::SuperAdminUser"]] 
=> #<ActiveRecord::Associations::CollectionProxy [#<Users::SuperAdminUser id: 1, email: "[email protected]", first_name: "Gregory", last_name: "Arnold", username: "garnold0", created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">, #<Users::SuperAdminUser id: 6, email: "[email protected]", first_name: "Nicole", last_name: "Cruz", username: "ncruz5", created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">]> 

    2.4.0 :004 > Accounts::Account.first.users_admin_users 
Accounts::Account Load (0.6ms) SELECT "accounts_accounts".* FROM "accounts_accounts" ORDER BY "accounts_accounts"."id" ASC LIMIT $1 [["LIMIT", 1]] 
Users::AdminUser Load (0.8ms) SELECT "users_admin_users".* FROM "users_admin_users" INNER JOIN "accounts_account_memberships" ON "users_admin_users"."id" = "accounts_account_memberships"."users_account_member_id" WHERE "accounts_account_memberships"."accounts_account_id" = $1 AND "accounts_account_memberships"."users_account_member_type" = $2 [["accounts_account_id", 1], ["users_account_member_type", "Users::AdminUser"]] 
=> #<ActiveRecord::Associations::CollectionProxy [#<Users::AdminUser id: 4, email: "[email protected]", first_name: "Henry", last_name: "Lane", username: "hlaned", created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">, #<Users::AdminUser id: 9, email: "[email protected]", first_name: "Raymond", last_name: "Harvey", username: "rharveyi", created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">]> 

    2.4.0 :005 > Accounts::Account.first.users_standard_users 
Accounts::Account Load (0.4ms) SELECT "accounts_accounts".* FROM "accounts_accounts" ORDER BY "accounts_accounts"."id" ASC LIMIT $1 [["LIMIT", 1]] 
Users::StandardUser Load (0.7ms) SELECT "users_standard_users".* FROM "users_standard_users" INNER JOIN "accounts_account_memberships" ON "users_standard_users"."id" = "accounts_account_memberships"."users_account_member_id" WHERE "accounts_account_memberships"."accounts_account_id" = $1 AND "accounts_account_memberships"."users_account_member_type" = $2 [["accounts_account_id", 1], ["users_account_member_type", "Users::StandardUser"]] 
=> #<ActiveRecord::Associations::CollectionProxy [#<Users::StandardUser id: 2, email: "[email protected]", first_name: "Gary", last_name: "Hamilton", username: "ghamiltonl", created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">, #<Users::StandardUser id: 7, email: "[email protected]", first_name: "Jonathan", last_name: "Kelly", username: "jkellyq", created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">]> 

    2.4.0 :006 > Accounts::Account.first.users_account_members 
Accounts::Account Load (0.6ms) SELECT "accounts_accounts".* FROM "accounts_accounts" ORDER BY "accounts_accounts"."id" ASC LIMIT $1 [["LIMIT", 1]] 
Users::SuperAdminUser Load (0.7ms) SELECT "users_super_admin_users".* FROM "users_super_admin_users" INNER JOIN "accounts_account_memberships" ON "users_super_admin_users"."id" = "accounts_account_memberships"."users_account_member_id" WHERE "accounts_account_memberships"."accounts_account_id" = $1 AND "accounts_account_memberships"."users_account_member_type" = $2 [["accounts_account_id", 1], ["users_account_member_type", "Users::SuperAdminUser"]] 
Users::AdminUser Load (0.6ms) SELECT "users_admin_users".* FROM "users_admin_users" INNER JOIN "accounts_account_memberships" ON "users_admin_users"."id" = "accounts_account_memberships"."users_account_member_id" WHERE "accounts_account_memberships"."accounts_account_id" = $1 AND "accounts_account_memberships"."users_account_member_type" = $2 [["accounts_account_id", 1], ["users_account_member_type", "Users::AdminUser"]] 
Users::StandardUser Load (0.7ms) SELECT "users_standard_users".* FROM "users_standard_users" INNER JOIN "accounts_account_memberships" ON "users_standard_users"."id" = "accounts_account_memberships"."users_account_member_id" WHERE "accounts_account_memberships"."accounts_account_id" = $1 AND "accounts_account_memberships"."users_account_member_type" = $2 [["accounts_account_id", 1], ["users_account_member_type", "Users::StandardUser"]] 
=> [#<Users::SuperAdminUser id: 1, email: "[email protected]", first_name: "Gregory", last_name: "Arnold", username: "garnold0", created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">, #<Users::SuperAdminUser id: 6, email: "[email protected]", first_name: "Nicole", last_name: "Cruz", username: "ncruz5", created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">, #<Users::AdminUser id: 4, email: "[email protected]", first_name: "Henry", last_name: "Lane", username: "hlaned", created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">, #<Users::AdminUser id: 9, email: "[email protected]", first_name: "Raymond", last_name: "Harvey", username: "rharveyi", created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">, #<Users::StandardUser id: 2, email: "[email protected]", first_name: "Gary", last_name: "Hamilton", username: "ghamiltonl", created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">, #<Users::StandardUser id: 7, email: "[email protected]", first_name: "Jonathan", last_name: "Kelly", username: "jkellyq", created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">] 

    2.4.0 :007 > Users::SuperAdminUser.first.accounts_accounts 
Users::SuperAdminUser Load (0.6ms) SELECT "users_super_admin_users".* FROM "users_super_admin_users" ORDER BY "users_super_admin_users"."id" ASC LIMIT $1 [["LIMIT", 1]] 
Accounts::Account Load (0.8ms) SELECT "accounts_accounts".* FROM "accounts_accounts" INNER JOIN "accounts_account_memberships" ON "accounts_accounts"."id" = "accounts_account_memberships"."accounts_account_id" WHERE "accounts_account_memberships"."users_account_member_id" = $1 AND "accounts_account_memberships"."users_account_member_type" = $2 [["users_account_member_id", 1], ["users_account_member_type", "Users::SuperAdminUser"]] 
=> #<ActiveRecord::Associations::CollectionProxy [#<Accounts::Account id: 1, name: "Ooba", users_account_owner_id: 1, created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">]> 

    2.4.0 :008 > Users::SuperAdminUser.second.accounts_accounts 
Users::SuperAdminUser Load (0.4ms) SELECT "users_super_admin_users".* FROM "users_super_admin_users" ORDER BY "users_super_admin_users"."id" ASC LIMIT $1 OFFSET $2 [["LIMIT", 1], ["OFFSET", 1]] 
Accounts::Account Load (0.7ms) SELECT "accounts_accounts".* FROM "accounts_accounts" INNER JOIN "accounts_account_memberships" ON "accounts_accounts"."id" = "accounts_account_memberships"."accounts_account_id" WHERE "accounts_account_memberships"."users_account_member_id" = $1 AND "accounts_account_memberships"."users_account_member_type" = $2 [["users_account_member_id", 2], ["users_account_member_type", "Users::SuperAdminUser"]] 
=> #<ActiveRecord::Associations::CollectionProxy [#<Accounts::Account id: 4, name: "Brainsphere", users_account_owner_id: 4, created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">]> 

    2.4.0 :009 > Users::AdminUser.first.accounts_accounts 
Users::AdminUser Load (0.4ms) SELECT "users_admin_users".* FROM "users_admin_users" ORDER BY "users_admin_users"."id" ASC LIMIT $1 [["LIMIT", 1]] 
Accounts::Account Load (0.6ms) SELECT "accounts_accounts".* FROM "accounts_accounts" INNER JOIN "accounts_account_memberships" ON "accounts_accounts"."id" = "accounts_account_memberships"."accounts_account_id" WHERE "accounts_account_memberships"."users_account_member_id" = $1 AND "accounts_account_memberships"."users_account_member_type" = $2 [["users_account_member_id", 1], ["users_account_member_type", "Users::AdminUser"]] 
=> #<ActiveRecord::Associations::CollectionProxy [#<Accounts::Account id: 2, name: "Avamba", users_account_owner_id: 2, created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">]> 

    2.4.0 :010 > Users::AdminUser.second.accounts_accounts 
Users::AdminUser Load (0.5ms) SELECT "users_admin_users".* FROM "users_admin_users" ORDER BY "users_admin_users"."id" ASC LIMIT $1 OFFSET $2 [["LIMIT", 1], ["OFFSET", 1]] 
Accounts::Account Load (0.7ms) SELECT "accounts_accounts".* FROM "accounts_accounts" INNER JOIN "accounts_account_memberships" ON "accounts_accounts"."id" = "accounts_account_memberships"."accounts_account_id" WHERE "accounts_account_memberships"."users_account_member_id" = $1 AND "accounts_account_memberships"."users_account_member_type" = $2 [["users_account_member_id", 2], ["users_account_member_type", "Users::AdminUser"]] 
=> #<ActiveRecord::Associations::CollectionProxy [#<Accounts::Account id: 5, name: "Wordtune", users_account_owner_id: 5, created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">]> 

    2.4.0 :011 > Users::StandardUser.first.accounts_accounts 
Users::StandardUser Load (0.5ms) SELECT "users_standard_users".* FROM "users_standard_users" ORDER BY "users_standard_users"."id" ASC LIMIT $1 [["LIMIT", 1]] 
Accounts::Account Load (0.7ms) SELECT "accounts_accounts".* FROM "accounts_accounts" INNER JOIN "accounts_account_memberships" ON "accounts_accounts"."id" = "accounts_account_memberships"."accounts_account_id" WHERE "accounts_account_memberships"."users_account_member_id" = $1 AND "accounts_account_memberships"."users_account_member_type" = $2 [["users_account_member_id", 1], ["users_account_member_type", "Users::StandardUser"]] 
=> #<ActiveRecord::Associations::CollectionProxy [#<Accounts::Account id: 3, name: "Linktype", users_account_owner_id: 3, created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">]> 

    2.4.0 :012 > Users::StandardUser.second.accounts_accounts 
Users::StandardUser Load (0.4ms) SELECT "users_standard_users".* FROM "users_standard_users" ORDER BY "users_standard_users"."id" ASC LIMIT $1 OFFSET $2 [["LIMIT", 1], ["OFFSET", 1]] 
Accounts::Account Load (0.6ms) SELECT "accounts_accounts".* FROM "accounts_accounts" INNER JOIN "accounts_account_memberships" ON "accounts_accounts"."id" = "accounts_account_memberships"."accounts_account_id" WHERE "accounts_account_memberships"."users_account_member_id" = $1 AND "accounts_account_memberships"."users_account_member_type" = $2 [["users_account_member_id", 2], ["users_account_member_type", "Users::StandardUser"]] 
=> #<ActiveRecord::Associations::CollectionProxy [#<Accounts::Account id: 1, name: "Ooba", users_account_owner_id: 1, created_at: "2017-02-11 21:01:57", updated_at: "2017-02-11 21:01:57">]> 

デシベル/ seeds.rb

Users::SuperAdminUser.create(email: '[email protected]',  first_name: 'Gregory', last_name: 'Arnold', username: 'garnold0') 
Users::SuperAdminUser.create(email: '[email protected]',  first_name: 'Lisa', last_name: 'Sanders', username: 'lsanders1') 
Users::SuperAdminUser.create(email: '[email protected]',  first_name: 'Scott', last_name: 'Sanders', username: 'ssanders2') 
Users::SuperAdminUser.create(email: '[email protected]',   first_name: 'Anthony', last_name: 'Roberts', username: 'aroberts3') 
Users::SuperAdminUser.create(email: '[email protected]', first_name: 'Paula', last_name: 'Robinson', username: 'probinson4') 
Users::SuperAdminUser.create(email: '[email protected]', first_name: 'Nicole', last_name: 'Cruz',  username: 'ncruz5') 
Users::SuperAdminUser.create(email: '[email protected]', first_name: 'George', last_name: 'Andrews', username: 'gandrews6') 
Users::SuperAdminUser.create(email: '[email protected]', first_name: 'Nicole', last_name: 'Wilson', username: 'nwilson7') 
Users::SuperAdminUser.create(email: '[email protected]',   first_name: 'Anne', last_name: 'Edwards', username: 'aedwards8') 
Users::SuperAdminUser.create(email: '[email protected]',  first_name: 'Ronald', last_name: 'Davis', username: 'rdavis9') 

Users::AdminUser.create(email: '[email protected]',   first_name: 'Lisa', last_name: 'Hawkins', username: 'lhawkinsa') 
Users::AdminUser.create(email: '[email protected]',   first_name: 'Helen', last_name: 'Taylor', username: 'htaylorb') 
Users::AdminUser.create(email: '[email protected]',   first_name: 'Gregory', last_name: 'Taylor', username: 'gtaylorc') 
Users::AdminUser.create(email: '[email protected]',  first_name: 'Henry', last_name: 'Lane',  username: 'hlaned') 
Users::AdminUser.create(email: '[email protected]', first_name: 'Harry', last_name: 'Phillips', username: 'hphillipse') 
Users::AdminUser.create(email: '[email protected]',   first_name: 'Jeffrey', last_name: 'Gonzales', username: 'jgonzalesf') 
Users::AdminUser.create(email: '[email protected]',   first_name: 'Lori', last_name: 'James', username: 'ljamesg') 
Users::AdminUser.create(email: '[email protected]nu.org',    first_name: 'Roger', last_name: 'Hill',  username: 'rhillh') 
Users::AdminUser.create(email: '[email protected]',  first_name: 'Raymond', last_name: 'Harvey', username: 'rharveyi') 
Users::AdminUser.create(email: '[email protected]',    first_name: 'Stephen', last_name: 'Perry', username: 'sperryj') 

Users::StandardUser.create(email: '[email protected]',  first_name: 'Michelle', last_name: 'Black',  username: 'mblackk') 
Users::StandardUser.create(email: '[email protected]', first_name: 'Gary',  last_name: 'Hamilton', username: 'ghamiltonl') 
Users::StandardUser.create(email: '[email protected]',    first_name: 'Chris',  last_name: 'Gray',  username: 'cgraym') 
Users::StandardUser.create(email: '[email protected]',  first_name: 'Jacqueline', last_name: 'Bradley', username: 'jbradleyn') 
Users::StandardUser.create(email: '[email protected]',   first_name: 'Joseph',  last_name: 'Payne',  username: 'jpayneo') 
Users::StandardUser.create(email: '[email protected]',  first_name: 'Debra',  last_name: 'Rodriguez', username: 'drodriguezp') 
Users::StandardUser.create(email: '[email protected]',   first_name: 'Jonathan', last_name: 'Kelly',  username: 'jkellyq') 
Users::StandardUser.create(email: '[email protected]',   first_name: 'Cheryl',  last_name: 'Reynolds', username: 'creynoldsr') 
Users::StandardUser.create(email: '[email protected]',    first_name: 'Kathleen', last_name: 'Barnes', username: 'kbarness') 
Users::StandardUser.create(email: '[email protected]',   first_name: 'Annie',  last_name: 'Hansen', username: 'ahansent') 

Accounts::Account.create(name: 'Ooba',  users_account_owner_id: 1) 
Accounts::Account.create(name: 'Avamba',  users_account_owner_id: 2) 
Accounts::Account.create(name: 'Linktype', users_account_owner_id: 3) 
Accounts::Account.create(name: 'Brainsphere', users_account_owner_id: 4) 
Accounts::Account.create(name: 'Wordtune', users_account_owner_id: 5) 

Accounts::AccountMembership.create(accounts_account_id: 1, users_account_member_type: 'Users::SuperAdminUser', users_account_member_id: 1) 
Accounts::AccountMembership.create(accounts_account_id: 2, users_account_member_type: 'Users::AdminUser',  users_account_member_id: 1) 
Accounts::AccountMembership.create(accounts_account_id: 3, users_account_member_type: 'Users::StandardUser', users_account_member_id: 1) 
Accounts::AccountMembership.create(accounts_account_id: 4, users_account_member_type: 'Users::SuperAdminUser', users_account_member_id: 2) 
Accounts::AccountMembership.create(accounts_account_id: 5, users_account_member_type: 'Users::AdminUser',  users_account_member_id: 2) 
Accounts::AccountMembership.create(accounts_account_id: 1, users_account_member_type: 'Users::StandardUser', users_account_member_id: 2) 
Accounts::AccountMembership.create(accounts_account_id: 2, users_account_member_type: 'Users::SuperAdminUser', users_account_member_id: 3) 
Accounts::AccountMembership.create(accounts_account_id: 3, users_account_member_type: 'Users::AdminUser',  users_account_member_id: 3) 
Accounts::AccountMembership.create(accounts_account_id: 4, users_account_member_type: 'Users::StandardUser', users_account_member_id: 3) 
Accounts::AccountMembership.create(accounts_account_id: 5, users_account_member_type: 'Users::SuperAdminUser', users_account_member_id: 4) 
Accounts::AccountMembership.create(accounts_account_id: 1, users_account_member_type: 'Users::AdminUser',  users_account_member_id: 4) 
Accounts::AccountMembership.create(accounts_account_id: 2, users_account_member_type: 'Users::StandardUser', users_account_member_id: 4) 
Accounts::AccountMembership.create(accounts_account_id: 3, users_account_member_type: 'Users::SuperAdminUser', users_account_member_id: 5) 
Accounts::AccountMembership.create(accounts_account_id: 4, users_account_member_type: 'Users::AdminUser',  users_account_member_id: 5) 
Accounts::AccountMembership.create(accounts_account_id: 5, users_account_member_type: 'Users::StandardUser', users_account_member_id: 5) 
Accounts::AccountMembership.create(accounts_account_id: 1, users_account_member_type: 'Users::SuperAdminUser', users_account_member_id: 6) 
Accounts::AccountMembership.create(accounts_account_id: 2, users_account_member_type: 'Users::AdminUser',  users_account_member_id: 6) 
Accounts::AccountMembership.create(accounts_account_id: 3, users_account_member_type: 'Users::StandardUser', users_account_member_id: 6) 
Accounts::AccountMembership.create(accounts_account_id: 4, users_account_member_type: 'Users::SuperAdminUser', users_account_member_id: 7) 
Accounts::AccountMembership.create(accounts_account_id: 5, users_account_member_type: 'Users::AdminUser',  users_account_member_id: 7) 
Accounts::AccountMembership.create(accounts_account_id: 1, users_account_member_type: 'Users::StandardUser', users_account_member_id: 7) 
Accounts::AccountMembership.create(accounts_account_id: 2, users_account_member_type: 'Users::SuperAdminUser', users_account_member_id: 8) 
Accounts::AccountMembership.create(accounts_account_id: 3, users_account_member_type: 'Users::AdminUser',  users_account_member_id: 8) 
Accounts::AccountMembership.create(accounts_account_id: 4, users_account_member_type: 'Users::StandardUser', users_account_member_id: 8) 
Accounts::AccountMembership.create(accounts_account_id: 5, users_account_member_type: 'Users::SuperAdminUser', users_account_member_id: 9) 
Accounts::AccountMembership.create(accounts_account_id: 1, users_account_member_type: 'Users::AdminUser',  users_account_member_id: 9) 
Accounts::AccountMembership.create(accounts_account_id: 2, users_account_member_type: 'Users::StandardUser', users_account_member_id: 9) 
Accounts::AccountMembership.create(accounts_account_id: 3, users_account_member_type: 'Users::SuperAdminUser', users_account_member_id: 10) 
Accounts::AccountMembership.create(accounts_account_id: 4, users_account_member_type: 'Users::AdminUser',  users_account_member_id: 10) 
Accounts::AccountMembership.create(accounts_account_id: 5, users_account_member_type: 'Users::StandardUser', users_account_member_id: 10) 
関連する問題