vendredi 12 juin 2015

Database Relationship Setup W/ Devise

I have a Ruby on Rails App that i am creating.

When i setup the Database I configured:

User.rb

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me, :company_id

  belongs_to :company, :dependent => :destroy

   ...
end

company.rb:

class Company < ActiveRecord::Base
  attr_accessible :address, :city, :mc, :name, :phone, :state, :zip, :tier_id, :entity_type
  has_many :users
end

I want to modify this so when a user signs up using the User Model that has devise. it can accept the nested Attributes of Company

so i want to add :companies_attributes to User attr_accessible

is this possible with the current setup or am i going to have to redo my setup so devise is on Company?

Aucun commentaire:

Enregistrer un commentaire