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
list_of_valid_states = ["Alava", "Albacete"....] | |
class OptionsValidator < ActiveModel::Validator | |
def validate(record) | |
unless list_of_valid_states.include?(record.state) | |
record.errors[:state] << 'This is not a valid state!' | |
end | |
end | |
end | |
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 User | |
after_create :create_relation | |
has_one :empresa | |
has_one :la_otra | |
def create_relation | |
kind == "empresa" ? create_empresa_relation : create_la_otra_relation | |
end | |
def create_empresa_relation |
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
Hugo-Rincons-MacBook-Air:FeedMob hugo$ rake db:schema:load | |
-- create_table("order_statuses", {:force=>true}) | |
NOTICE: CREATE TABLE will create implicit sequence "order_statuses_id_seq" for serial column "order_statuses.id" | |
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "order_statuses_pkey" for table "order_statuses" | |
-> 0.0383s | |
-- create_table("orders", {:force=>true}) | |
NOTICE: CREATE TABLE will create implicit sequence "orders_id_seq" for serial column "orders.id" | |
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "orders_pkey" for table "orders" | |
-> 0.0074s | |
-- create_table("products", {:force=>true}) |