초보자는 프로젝트에 뛰어 들어 레일에 루비를 배우게됩니다. 이 질문은 아마도 순수 루비이며 레일과 관련이 없습니다. 나는 또한 내가 Active_Admin을 사용하고 있음을 주목하고 싶다.클래스 변수 사용
본인에게는 소유자와 전화의 두 가지 수업이 있습니다.
class Owner < ActiveRecord::Base
attr_accessible :email, :password,
has_many :phones
end
class Phone < ActiveRecord::Base
attr_accessible :owner_id :model
belongs_to :owner
end
어떻게 예를 들어, 소유자가 휴대폰 모델 내에서 이메일에 접근 갈 것 : 나는 곡괭이 책을 검토하고 레일로 점프하기 전에 내 루비를 수정해야처럼
form do |f|
f.inputs "Phone Details" do
f.input :model
f.input :owner_id # This is where I want the email, not the owners id.
end
f.buttons
end
것 같습니다. 소유자와 하나 개의 형태로 전화를 모두 가지고
감사