diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2013-04-13 21:19:17 -0400 |
---|---|---|
committer | Neeraj Singh <neerajdotname@gmail.com> | 2013-04-19 14:09:16 -0400 |
commit | 66001f360661fefad89d9e271b9ff75a86b4b886 (patch) | |
tree | 838c9686ec081959b7e6f9b007f290212d3bad25 /.gitignore | |
parent | 08c6df8532a1884050c8e9087e9fce9df6528ae2 (diff) | |
download | rails-66001f360661fefad89d9e271b9ff75a86b4b886.tar.gz rails-66001f360661fefad89d9e271b9ff75a86b4b886.tar.bz2 rails-66001f360661fefad89d9e271b9ff75a86b4b886.zip |
fix respond_to? for non selected column
fixes #4208
If a query selects only a few columns and gives custom names to
those columns then respond_to? was returning true for the non
selected columns. However calling those non selected columns
raises exception.
post = Post.select("'title' as post_title").first
In the above case when `post.body` is invoked then an exception is
raised since `body` attribute is not selected. Howevere `respond_to?`
did not behave correctly.
pos.respond_to?(:body) #=> true
Reason was that Active Record calls `super` to pass the call to
Active Model and all the columns are defined on Active Model.
Fix is to actually check if the data returned from the db contains
the data for column in question.
Diffstat (limited to '.gitignore')
0 files changed, 0 insertions, 0 deletions