wrong number of bind variables (0 for 2) in: first_name = ? AND last_name = ? I''m not sure why I"m getting this error ? def self.authenticate(first_name, last_name, password) user = User.find(:first, :conditions => [''first_name = ? AND last_name = ?'']) if user.blank? Digest::SHA256.hexdigest(password + user.password_salt) !user.password_hash raise "Username or password invalid" end user end end should it be user = User.find(:first, :second, :conditions ................ Or would it be something else ? Stuart
On 8/7/06, Dark Ambient <sambient@gmail.com> wrote:> wrong number of bind variables (0 for 2) in: first_name = ? AND last_name = ? > > I''m not sure why I"m getting this error ? > > def self.authenticate(first_name, last_name, password) > user = User.find(:first, :conditions => [''first_name = ? AND > last_name = ?'']) > if user.blank? > Digest::SHA256.hexdigest(password + user.password_salt) !> user.password_hash > raise "Username or password invalid" > end > user > end > end > > should it be user = User.find(:first, :second, :conditions ................ > > Or would it be something else ?user = User.find(:first, :conditions => [''first_name = ? AND last_name = ?'']) The two question marks mean you will be sending two additional values in the array, something like this perhaps: user = User.find( :first, :conditions => [ ''first_name = ? AND last_name = ?'', ''foo'', ''bar'' ] ) -- Greg Donald http://destiney.com/
user = User.find(:first, :conditions => [''first_name = ? AND last_name = ?'',first_name, last_name]) Stuart Fellowes wrote:> wrong number of bind variables (0 for 2) in: first_name = ? AND > last_name = ? > > I''m not sure why I"m getting this error ? > > def self.authenticate(first_name, last_name, password) > user = User.find(:first, :conditions => [''first_name = ? AND > last_name = ?'']) > if user.blank? > Digest::SHA256.hexdigest(password + user.password_salt) !> user.password_hash > raise "Username or password invalid" > end > user > end > end > > should it be user = User.find(:first, :second, :conditions > ................ > > Or would it be something else ? > > Stuart-- Posted via http://www.ruby-forum.com/.