레일스를 처음 사용하고 Simple_Form, Devise 및 체크 박스와 관련된 문제가 있습니다.레일 Simple_Form 복수 선택 체크 박스
사용자가 하나 이상의 체크 박스를 체크하려는 컬럼을 포함하여 내 Devise 모델에 몇 가지 추가 열을 추가했습니다. 운영의
지역 :이 유사 [] 잉글랜드 [] 웨일즈 [] 스코틀랜드
모든 것은 괜찮지 만, 나는 여러 영역이 다음 저장을 선택하면, 선택 항목은에 저장하지 마십시오 데이터 베이스.
은 여기 내 보기 코드의 [응용 프로그램/뷰/궁리/등록/edit.html.erb] : 여기
<%= simple_form_for(resource, html: { class: 'form-horizontal'}, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
<%= f.input :areas, :as => :check_boxes, :collection => ["England", "Wales", "Scotland", "Northern Ireland"] %>
<% end %>
그리고 내 와 ApplicationController 코드 [응용 프로그램/컨트롤러입니다 /application_controller.rb] :
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) << :areas
devise_parameter_sanitizer.for(:account_update) << :areas
end
end
분명히 뭔가 빠진 것이 틀림 없습니다.하지만 몇 시간 동안 인터넷 검색을 해왔습니다.
도움이 될 것입니다.
편집 :
죄송합니다.
영역을 저장하는 방법에는 여러 가지가 있습니다create_table "providers", force: true do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at"
t.datetime "updated_at"
t.string "first_name"
t.string "last_name"
t.string "organisation"
t.string "street"
t.string "city"
t.string "county"
t.string "postcode"
t.string "areas"
t.string "methods"
end
add_index "providers", ["email"], name: "index_providers_on_email", unique: true
add_index "providers", ["reset_password_token"], name: "index_providers_on_reset_password_token", unique: true
정보를 너무 적게 제공했습니다. db 스키마 란 무엇입니까 (데이터베이스에 표시된 영역은 어떻게 의미합니까?). – Lucas
'areas'는 연관성이 있습니까? – kobaltz
@Lucas - 사과. 스키마를 포함하도록 내 질문을 업데이트했습니다. – diferse