search for: active_record_extensions

Displaying 3 results from an estimated 3 matches for "active_record_extensions".

2009 Mar 24
12
MonkeyPatching ActiveRecord::Base class
...classes which need this functionality. Since model classes directly inherit from ActiveRecord::Base and unlike controllers and helpers, do not have an ancestor class defined, I think I am forced to open the ActiveRecord::Base class and patch it? May be I am wrong. Anyway, here is my code in the active_record_extensions.rb file that I created in the RAILS_ROOT/lib directory: module ActiveRecord class Base def self.search(search, current_page) if search.blank? paginate(:all, :page => current_page || 1, :per_page => 5) else paginate(:all, :conditions => ["name LIKE ?...
2005 Dec 05
0
bug in bubbleshare's Active Record extensions?
..."tracks", :foreign_key => "artist_id" remove_foreign_key_constraint "albums", :foreign_key => "artist_id" end end AddConstraints.up works jim dandy -- I can fire up psql and see the schema correctly modified, using the naming scheme defined in active_record_extensions.rb. Attempting to down-migrate, though, causes the system to puke thusly: > rake --trace environment RAILS_ENV=production VERSION=3 migrate (in /Users/ogd/Documents/projects/euterpe) ** Invoke environment (first_time) ** Execute environment ** Invoke migrate (first_time) ** Invoke environment...
2010 Aug 08
0
User[17]
In Rails 2.3.8 if you put this in RAILS_ROOT/initializers/ # active_record_extensions.rb module ActiveRecord class Base class << self def [](index) find(index) end end end end Then you can access like an array: User[17] instead of the more verbose: User.find(17) Personally, I think it''s kinda nice. David :) -- You received thi...