Last active
December 22, 2015 03:39
-
-
Save vsizov/6411954 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersField < ActiveRecord::Base | |
belongs_to :user | |
belongs_to :field | |
has_one :fields_group, through: :field | |
validates :value, allow_blank: true | |
def create_record | |
if !self.field.required & self.value.blank? | |
return nil | |
else | |
super | |
end | |
end | |
# # Creates a record with values matching those of the instance attributes | |
# # and returns its id. | |
# def create_record(attribute_names = @attributes.keys) | |
# attributes_values = arel_attributes_with_values_for_create(attribute_names) | |
# new_id = self.class.unscoped.insert attributes_values | |
# self.id ||= new_id if self.class.primary_key | |
# @new_record = false | |
# id | |
# end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment