1

script/console output:

>> User.find(:first, :select => '`email`, `pass`, `login`, `id`')
=> #<User pass: "e10adc3949ba59abbe56e057f20f883e", email: "[email protected]">
>> User.find(:first, :select => '`pass`, `login`, `id`')
=> #<User login: "ostap", pass: "e10adc3949ba59abbe56e057f20f883e">

how i can fix it? Unix hosting, Ruby 1.8.7, Rails 2.3.5, MySQL 5.1.46

in mysql console all fine...

1 Answer 1

1

Try changing ":select => 'pass, login, id'" to :select => 'email, pass, login, id'; i.e. remove the backticks around the fields. I think the backticks in your argument are throwing off the select. Here is the API dock for the find command that lead me to that conclusion.

Sign up to request clarification or add additional context in comments.

7 Comments

>> User.find(:first, :select => 'email, pass, login, id') => #<User pass: "e10adc3949ba59abbe56e057f20f883e", email: "[email protected]"> >> User.find(:first) => #<User id: 1, login: "ostap"> Its doesnt work...
I don't know if this is a pattern but for some suspicious reason only the first two columns are shown. No matter what you selected. Did you check if the attributes are set actually? Maybe they are not shown only.
@iltempo what attributes? and how i can check this?
Call User.find(:first, :select => 'email, pass, login, id').login.
>> User.find(:first, :select => 'email, pass, login, id').login ActiveRecord::MissingAttributeError: missing attribute: login from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:244:in send from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:244:in method_missing from (irb):1
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.