I have a standard Rails 2.3.5 application with a Post model. Post has a url attribute, and the following getter is defined:
def url p = 'http://' u = self[:url] u.starts_with?(p) ? u : "#{p}#{u}" end
If I load script/console , I can do Post.first.url and get the desired result (for example, it returns http://foo.com if the true value of the attribute is foo.com)
However, if I have a form_for block and do something like form.text_field :url , it will not return the url with http: // prefixed; rather, it just returns foo.com
How are access form_for attributes on ActiveRecord models? It seems that he walked around all the overloaded getters.
overloading ruby-on-rails activerecord getter attributes
Kyle
source share