An ActiveRecord method I did not existed: becomes.
Returns an instance of the specified klass with the attributes of the current record. This is mostly useful in relation to single-table inheritance structures where you want a subclass to appear as the superclass. This can be used along with record identification in Action Pack to allow, say, Client < Company to do something like render :partial => @client.becomes(Company) to render that instance using the companies/company partial instead of clients/client. Note: The new instance will share a link to the same attributes as the original class. So any change to the attributes in either instance will affect the other.Blog
About this Blog
This blog is no longer being maintained. The blog once was a part of my Ruby on Rails freelancing practice. If you would like to find out what I'm currently working on, please visit CivilCode Inc - Custom Software Development; we specialize in building tailored business application in Elixir and Phoenix.
Blog Archive
-
▼
2010
(70)
-
▼
October
(16)
- CarrierWave, an alternative to PaperClip for Uploa...
- Redmine Estimated Time Summary Plugin
- Rail's ActiveRecord: include vs join
- ActiveRecord::Base#becomes
- Web Integrator Application Hand-off Checklist
- Rails UJS using jQuery results in Unknown File Typ...
- Unix History Commands
- Cached Key for ActiveRecord Collections
- Slow startup with Rspec (1.3.0) and Spork
- Ensure all your external assets are SSL too
- Pushing specific tags to Heroku
- Allow the designer to easily preview Rails applica...
- Using rails.js, Rails 3 UJS in Rails 2 application
- Keeping it fun, knowing when to stop
- Installing Redmine on Heroku with S3 Storage: Step...
- Collapsing Margins in CSS
-
▼
October
(16)
Labels
- active-record (6)
- agile (5)
- application development (4)
- application-architecture (1)
- ask for help (1)
- associations (3)
- blank-static (2)
- bourne (2)
- bundler (1)
- business (1)
- capistrano (1)
- capybara (1)
- centos (2)
- checklists (11)
- compass (2)
- content management systems (3)
- craftmanship (1)
- css (7)
- cucumber (4)
- cufon (1)
- customer-centered web design (4)
- developer-challenge (4)
- domain-modelling (1)
- domain-patterns (1)
- ebooks (1)
- elixir (1)
- ember.js (1)
- error-handling (1)
- errors (1)
- facebook (1)
- fundamentals (3)
- gems (2)
- git (4)
- google-site-search (1)
- haml (1)
- heroku (9)
- html (3)
- html-5 (1)
- i18n (1)
- internet-explorer (2)
- interview (1)
- javascript (1)
- jquery (4)
- launch (10)
- life hacks (2)
- maintenance (1)
- memcached (1)
- memory-consumption (1)
- meta-programming (3)
- mocha (2)
- mocks (1)
- monitoring (1)
- mysql (1)
- named scopes (3)
- object-design (2)
- optimization (1)
- osx (2)
- personas (4)
- presentations (4)
- productivity (1)
- radiant (4)
- rails (35)
- rails-3.0 (5)
- rails-3.2 (1)
- railsconf (2)
- rake (1)
- rdoc (1)
- redmine (3)
- refinery (1)
- rest (1)
- rmagick (1)
- rspec (12)
- ruby (18)
- rvm (1)
- s3 (1)
- safari (1)
- sass (2)
- saving (2)
- searchlogic (1)
- sftp (1)
- shopify (1)
- spork (1)
- spree (2)
- sql (1)
- stand-up (7)
- static-matic (2)
- strategy (1)
- templates (1)
- testing (4)
- textmate (1)
- tools (1)
- unix (2)
- uploads (1)
- usability (1)
- user-stories (1)
- validations (1)
- vim (3)
- web design (1)
- workflow (2)
Firsthand Blog Archive
2002-2019 Nicholas Henry
All Rights Reserved