I have Site Model and i wanted to find all associated models of Site model which are having belongs_to relationship.After doing lot headache, here is the solution i foundhas_many models of Site Model Site.reflect_on_all_associations.map{|mac| mac.class_name if mac.macro==:has_many}.compact=> ["Layout", "User", "SubmenuLink", "Snippet", "Asset"]belongs_to model of Site ModelSite.reflect_on_all_associations.map{|mac| mac.class_name if mac.macro==:belongs_to}.compact=> ["User", "Page", "User"]To get all associationsSite.reflect_on_all_associations.map{|mac| … Continue reading How to get all associted models of rails model
Category: Ruby on Rails
bundling gems in rails application
Gem Bundling is basically used to maintain all required gems at your application level.It downloads necessary gems and maintain it under "/vender/gems" directory.Its very easy to use gem bundle.1. Insatll gemcutter gem ( Its gem hosting )gem install gemcutter2. Install bundler ( Its a tool that manages gem dependencies for your ruby application. )gem install bundler3. … Continue reading bundling gems in rails application
Migrating an existing deployment to Heroku
It was fun -- pure unadulterated fun!! Now, I started looking at heroku since our current deployment on a linode was getting a little bulky. Our client has been complaining of 'suddenly things slowing down' and 'site not working'. The site is used at a hit rate of 36 Requests per minute and we need … Continue reading Migrating an existing deployment to Heroku
