ostapische
ostapische

Reputation: 1592

rails select only 2 columns error

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...

Upvotes: 1

Views: 518

Answers (1)

ScottJShea
ScottJShea

Reputation: 7111

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.

Upvotes: 1

Related Questions