안녕하십니까. 여기에 사용자를위한 신원 확인을위한 몇 가지 문제점이 있습니다.어떻게이 Devise 인증 문제를 해결할 수 있습니까?
내 응용 프로그램에는 color 및 sub_color라는 두 가지 모델이 있습니다. sub_color belongs_to 색상 및 색상 has_many sub_colors.I 이미 적절한 데이터와 함께 데이터베이스를 시드했습니다
도전입니다; 사용자가 collection 객체로 등록 할 때 dev_form_for에서 이들을 선택할 수 있기를 원하고 sub_color의 id는 특정 사용자를 식별하는 데에도 사용됩니다 (예를 들어 모든 사용자를 정렬 할 수있는 상황 파란색의 파란색). 이걸 어떻게 성취합니까?
이
내가 시도한 것입니다하지만이 작동하지 않습니다 :%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :user_name, required: true %>
<%= f.input :password, required: true, hint: ("# {@minimum_password_length} characters minimum" if @minimum_password_length) %>
<%= f.input :password_confirmation, required: true %>
<%= f.input :first_name, required: true %>
<%= f.label :color_id, "Color" %> <br/>
<%= f.collection_select :color_id, Color.order(:name), :id, :name, include_blank: true%>
<%= f.label :sub_color_id, "Sub Color" %> <br/>
<%= f.grouped_collection_select :sub_color_id, Color.order(:name), :sub_color, :name, :id, :name, include_blank: true%>
<div class="form-actions">
<%= f.button :submit, "Sign up" %>
</div>
model for users:
belongs_to :sub_color
has_one :color, through: :sub_color
devise.......
end
model for sub_color
has_many :users
belongs_to :color
end
model for color
has_many :sub_color
end
이 내가
NoMethodError in Devise::Registrations#new
[undefined method `color_id' for #<User:0xbacc720>]
사용자 모델에'color_id'와'sub_color_id'가 있습니까? –
아니, 그게 없지만 지금은 선물이야. 고맙지 만 여전히 모델에 RSB의 대답을 사용하는 데 어려움이있다. – Dlaw
사용자, 색상 및 하위 색상 모델 및 해당 필드로 업데이트 질문을 할 수 있습니까? –