마이그레이션을 실행 한 다음 내용으로 된 Devise User 모델이 있습니다.마이그레이션을 실행 한 후 모델 연결 변경
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :token_authenticatable, :confirmable, :lockable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :role
# attr_accessible :title, :body
ROLES = ['admin', 'network/system admin', 'manager', 'programmer']
def role?(base_role)
ROLES.index(base_role.to_s) <= ROLES.index(role)
end
end
나중에 두 줄을 동일한 모델에 추가하고 티켓, 프로젝트 및 과제에 대한 이전을 실행합니다.
has_many :projects, :through => :assignments
has_many :tickets
위와 같이 사용자와 티켓 및 프로젝트와의 연관성을 업데이트합니까? 같은 마이그레이션을 실행 한 후 모델에서 연결을 변경하는 데 문제가 있습니까? 지금 Rails 앱을 개발할 때 알고 싶습니다.
감사합니다 :) -
연결에 대한 변경 사항에 따라 다릅니다. 몇 가지 코드를 포함시켜 주시겠습니까? – Dogbert
나는 진실하고 명확한 질문을 확실히 하였음을 확신한다. 투표를 거절 한 사람은 이유를 언급하십시오. –
@ 도버트 : 질문을 업데이트했습니다. 보세요 –