has_many => through association for rails polymorphic model

Example of polymorphic association using has_many, through, source.class student  has_many :posts, :as => authorendclass teacher  has_many :posts, :as => authorendclass post  belongs to :author, :polymorphic => trueendclass division  has_many :students  has_many :student_posts, :through => :students, :source => :postsendruby script/consolediv = Division.firstdiv.student_postsCheers !S@ndip

nginx passenger configuration for rails application

#user  nobody;user www-data;worker_processes  2;#error_log  logs/error.log;#error_log  logs/error.log  notice;#error_log  logs/error.log  info;#pid        logs/nginx.pid;events {    worker_connections  1024;}http {    passenger_root /var/lib/gems/1.8/gems/passenger-2.2.8;    passenger_ruby /usr/bin/ruby1.8;    passenger_max_pool_size 3;    include       mime.types;default_type  application/octet-stream;    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '    #                  '$status $body_bytes_sent "$http_referer" '    #         … Continue reading nginx passenger configuration for rails application

ActiveRecord::ReadOnlyRecord while updating object fetched by joins

ActiveRecord find with join options retrieves object as readonly.station = Station.find( :first, :joins => :call, :conditions => ["customer_id = ? and date(insurance_expiry_date) = ?", customer.id, insurance_expiry_date ] )Readonly object cannot modified. station.update_attributes({ :customer_id => 12 })should raise following error.ActiveRecord::ReadOnlyRecordIf you wanted to do write on object then you need to pass following option to find query.:readonly … Continue reading ActiveRecord::ReadOnlyRecord while updating object fetched by joins