Bind variables error

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

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

On 8/7/06, Dark A. [email protected] wrote:

  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’ ] )

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs