ruby on rails - Having trouble with Terms of Service and Mongoid -


hey have simple rails app setup devise model named worker , regular model named user.

worker:   has_one :user, as: :account, autobuild: true   accepts_nested_attributes_for :user  user:   belongs_to :account, polymorphic: true   accepts_nested_attributes_for :account 

on user model have boolean field :tos default :false. when user creates new devise account on sign_up page want take in tos checkbox input worker[user_attributes][tos] , on user model validate acceptance , store value true on model :tos field.

my checkbox:

%input{ name: 'worker[user_attributes][tos]', type: 'checkbox', value: '1' } 

my user validation:

validates_acceptance_of :tos, allow_nil: false, on: :create 

for reason tho doesn't seem validation works, there configuration have make devise make happen? if take out validation account created , tos remains false in database , if add validation , check box says validation failed.

instead of saving tos each user,remove migration following

attr_reader :tos validates_acceptance_of :tos 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -