May
20th
Tue
20th
Google AdSense made no sense for me. Turned it off
Hey, I'm Dima Sabanin and I love programming and I've been doing this since I was 10 years old. For the last 3 years I work with Rails.
I study Zen, I have a family with a small kid. This is my brain dump.
Email: sdmitry@gmail.com
class Blah < ActiveRecord::Base
has_many :somethings
end
class Something < ActiveRecord::Base
def self.for(person)
find(:first, :conditions => {:owner_name => person})
end
end
# And then later
@the_blah.somethings.for("dima") # => #<Something ....>
But I also can accidentally do this and break the expectation for the code, since I don’t have full conditions specified in the Something.for method:
Something.for("dima")
class Something < ActiveRecord::Base
def self.for(person)
raise unless scoped?(:find)
find(:first, :conditions => {:owner_name => person})
end
end
We are running contests on two sites, giving away multiple paid Beanstalk accounts for one year. If you like Beanstalk and want a free paid plan for a year, check out these sites.