Content

File: active record

I personally don’t think this is all that exciting — but I see this question asked a lot and just want something to point at from now on.
Say you have several ‘nested’ has_many relations:

class State < ActiveRecord::Base
has_many :cities
end

class City < ActiveRecord::Base
has_many :streets
belongs_to :state
end

class Street < ActiveRecord::Base
has_many :houses
[...]

4 comments  ::  (Read the rest of this)

Every once in a while I see this little code snippet show up somewhere:

script_console_running = ENV.include?(‘RAILS_ENV’) &&
IRB.conf[:LOAD_MODULES] &&
[...]

 ::  (Read the rest of this)