activerecord · multiple-models · Rails · rails-environments · rubyonrails

How to find different environment configurations in rails

While working with a multiple-database application I came across the point where I had to juggle between different environment configurations. I had to pass connection hash to ActiveRecord::Base.establish_connection, something like this: ActiveRecord::Base.establish_connection ( :adapter=>"mysql", :host=>"localhost", :username=>"myuser", :password=>"mypass", :database => "somedatabase" ) This connection can be easily retrieved from ActiveRecord::Base.configurations, this is currently undocumented. Using ActiveRecord::Base.configurations,… Continue reading How to find different environment configurations in rails

Advertisements
activerecord · Rails

ActiveRecord : an interesting observation

While working with ActiveRecord I observed something interesting, worth sharing. Say we have the relation: author has_many books Now I create a new author say 'a' and a new book say 'b' a = Author.new b = Book.new Now, If I have a piece of code where I push 'b' into 'a' without saving 'a'… Continue reading ActiveRecord : an interesting observation