Created
April 23, 2013 01:32
-
-
Save karmiclychee/5440150 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 Project < ActiveRecord::Base | |
belongs_to :collection | |
has_many :items | |
attr_accessible :name, :description, :links | |
attr_accessor :image | |
serialize :links | |
validates :name, uniqueness: { scope: :collection_id }, length: {minimum: 1, maximum: 20}, allow_blank: false | |
validates :description, length: {minimum: 5, maximum: 200}, allow_blank: true | |
def set_image | |
self.image = self.items.first.image | |
end | |
end |
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
[57] pry(main)> a.set_image | |
NoMethodError: undefined method `set_image' for #<Project:0x00000008272510> | |
from /home/jayml/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.13/lib/active_model/attribute_methods.rb:407:in `method_missing' | |
[59] pry(main)> Project.set_image | |
NoMethodError: undefined method `set_image' for #<Class:0x0000000853acc0> | |
from /home/jayml/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/dynamic_matchers.rb:55:in `method_missing' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment