Last active
August 29, 2015 14:10
-
-
Save alecguintu/c9cb5c29398e08575250 to your computer and use it in GitHub Desktop.
This file contains 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 Shelf < ActiveRecord::Base | |
has_many :comics | |
has_many :books#, validate: -> {self.shelf_of == 'book'} | |
accepts_nested_attributes_for :comics | |
accepts_nested_attributes_for :books | |
# has a dropdown on view for shelf_of that could either be 'comic' or 'book | |
validates :shelf_of, inclusion: { within: %w(comic book) } | |
end | |
class Comic < ActiveRecord::Base | |
end | |
class Book < ActiveRecord::Base | |
validates :title, format: { with: /\Asome_complicated_format\z/i } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment