Last active
August 29, 2015 14:10
-
-
Save alecguintu/c9cb5c29398e08575250 to your computer and use it in GitHub Desktop.
Revisions
-
alecguintu revised this gist
Dec 2, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ 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 -
alecguintu revised this gist
Dec 2, 2014 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,18 @@ class Shelf < ActiveRecord::Base has_many :comics has_many :books 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 -
alecguintu created this gist
Dec 2, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ class Shelf < ActiveRecord::Base has_many :comics accepts_nested_attributes_for :comics end class Comic < ActiveRecord::Base end class Book < ActiveRecord::Base validates :title, presence: true end