Skip to content

Instantly share code, notes, and snippets.

@karmiclychee
Created April 23, 2013 01:32
Show Gist options
  • Save karmiclychee/5440150 to your computer and use it in GitHub Desktop.
Save karmiclychee/5440150 to your computer and use it in GitHub Desktop.
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
[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