class ActiveRecord::Base def self.multilingual_field(fieldname) module_eval <<-end_eval def #{fieldname} send("#{fieldname}_\#{Locale.language.short_name}") end def #{fieldname}=(value) send("#{fieldname}_\#{Locale.language.short_name}=",value) end end_eval end end
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
ActiveRecord attribute calls interception (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
» Custom Validation in ActiveR... in activerecord rubyonrails validation
» A query from ActiveRecord th... in sql activerecord
» start my lighttpd-based rail... in lighttpd rubyonrails
» Select a State in Rails in rubyonrails
» Import of old Instiki data t... in rubyonrails
» link_to_remote not calling "... in rubyonrails
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails