Displaying 20 results from an estimated 4000 matches similar to: "Bind variables error"
2006 Aug 07
3
wrong number of bind variables
I''m getting this error message since i moved alot of the database
logic to the model.
wrong number of bind variables (0 for 2) in: first_name = ? AND last_name = ?
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 +
2006 Aug 07
8
Login form question
I''m using Rails Recipes to create a login form but instead of username
and password, my setup is firstname, lastname, password.
I seemed to be gramatically challenged and not sure how to set up the
parameter list. Can anyone offer up a suggestion.
The book shows the method starting like:
if request.post?
user = User.find(:first, :conditions => [''username = ?'' ,
2006 Jul 27
2
Creating multiple objects from form data
I''m in the process of creating a sign up form for an online application.
The form collects account info, company info, and then info for an
administrative user.
The method looks like this:
def create
@account = Account.create!(params[:account])
@company = @account.companies.create!(params[:company])
@user = @company.users.create!(params[:user])
end
However, this inevitably fails
2006 Aug 04
1
Need a better undersanding of form helpers
perhaps someone can take a little time to give me a better
understanding of how to use form helpers.
Here is what I''m working with in my app:
user model - (the table where a user registers their information)
it contains the following fields -
first_name
last_name
email
account_type (currently set to string but will probably be a select
box with options)
password_salt (I''m
2006 Apr 21
1
Catch authentication result from a model in a controller
Im still following the authorization recipe from the book, now all works
fine but im getting trouble in how handle the model authorization
result, if the user and pass are correct, it goes to a welcome
screen(admin.rhtml) but if wrong the model prints a message in an ugly
exception like page "usr and pass not correct", i want to redirect the
user to the login
2006 Aug 07
1
Help please: database column not taking
I created a simple registration form. One column doesn''t seem to be
taking the input. I''ve yet to put in any validation or error
checking.
The column in the database is called ''level'' and is type ''int''
The controller method is fairly simple:
def register
c = User.new(params[:user])
c.save
redirect_to :controller =>
2006 Aug 02
3
Need help with registration page
I have most of my books open as I''m trying to create this app. Still
not sure how to make this work - hopefully some help / hints can get
me further.
First I used the "authorizing users" recipe from Rails Recipes. Though
I did add some more generic type of registration fields (email,
address, etc).
I want the registration form on the main page(index) of the site.
What I have
2006 May 29
9
design recommendations for authenticating users with lots of different attributes..?
I''ve been struggling a bit trying to figure out the best way to
design/implement a system with authentication/authorization, and was
hoping some of you may be able to offer some advice..
At the moment, I have a system with 4 different types of users -
clients, administrators, sales_reps, and public_users. I''m using
"Authorizing Users with Roles" from the Rails Recipes
2006 Apr 14
7
SHA2 Issues
Hello all,
Thank you in advance for your help with this. I am trying to implement
the user authentication method from Ruby Recipes which calls for the use
of SHA 2. Here is the code for the password:
def password=(pass)
salt = [Array.new(6){rand(256).chr}.join].pack("m").chomp
self.password_salt, self.password_hash = salt,
Digest::SHA256.hexdigest(pass + salt)
end
I open
2006 Mar 04
4
Two quick newbie questions
2 quick questions regarding authentication ...
1) the flash[:notice] on successful login looks completely wrong to me.
How should it be done?
def index
if request.post?
@user = User.new(params[:user])
authentic_user = @user.attempt_login
if authentic_user
session[:user_id] = authentic_user.id
flash[:notice] =
''Login successful! Welcome
2006 Aug 16
5
validation on methods that aren''t part of the database.
using the Rails Recipes book, i went through the tutorial on setting up
authentication on a site. the tutorial was great, but it raises a few
questions.
the fields in the database are password_hash, and password_salt. the
tutorial creates another method for password that takes the value it was
given and hashes it and adds the 6 character salt at the end.
what if i want to perform validation
2006 Mar 02
8
User Authentication
I''m trying to create a simple authentication system but am failing
miserably. I''m (sort of) following the "Logging In" chapter of the Agile
book. Ideally, any access to http://example.com/publish (and any of its
subdirectories) should redirect to http:/example.com/publish/login when
there is no valid session user_id.
Code so far:
2006 Jul 22
3
refactoring commonly used aggregations
I have a number of models that use an aggregation to combine First Name,
Middle Initial and Last Name and they have been working fine. I am
looking to clean this up, DRY it if possible.
I have things like this in application.rb
class Clwholename
attr_reader :first_name, :middle_initial, :last_name
def initialize(first_name, middle_initial, last_name)
@first_name = first_name
2006 Jun 09
18
Is IRB the ruby console ?
I''m running script/console but keep getting the message that irb.bat is not
recognized as an internal or external command, operable program or batch
file.
If it means anything I am running instant rails. I can invoke irb straight
forward.
TIA
Stuart
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2006 Jan 19
2
Simple Ferret Questions
I am trying to use Ferret for searching for users based on first and last name.
In my index, I am adding the first_name, last_name, and a full_name
which is basically "#{first_name} #{last_name}".
I am searching the index using something like the following query:
INDEX.search_each(%Q/first_name:#{query}* OR last_name:#{query}* OR
full_name:#{query}*/) do |doc, score|
The problem I am
2006 May 17
5
text_field_with_auto_complete (newbie question)
I have the text_field_with_auto_complete woking on my user DB using
last_name. so looking for ''ivanoff'' works great, but I can''t find
''john''. Plus I like to have ''last_name, first_name'' show up in the
dropdown.
what I can''t figure out is how to concat first_name and last_name to
make a name and use that to look it.
working
2007 Aug 26
2
Multi-word query searching across columns
I''m trying to implement a basic name search on a People table with
separate first_name and last_name columns. I am using the
will_paginate plugin and have the following search method in the
model:
def self.search(search, page)
paginate :page => page,
:conditions => ["lower(last_name) like ? or
lower(first_name) like ?",
2007 May 30
4
aaf and dynamic attrs: a bug?
Hi!
I faced some issue while using it for dynamic attrs indexing/search.
Maybe I made something wrong. Here is test method. Everything works just
fine until last line http://pastie.caboo.se/66274 . Tested on both
stable and trunk of aaf and ferret 0.11.4.
the short version of code below:
Contact.acts_as_ferret :fields => [ :first_name ]
assert
2010 Oct 05
2
Is it possible to query on virtual attributes?
I have a Person model with attributes first_name and last_name.
I want to implement autocomplete search that looks that the entire
name. Hence I have a method:
def full_name
self.first_name + " " + self.last_name
end
Is it possible for me to query on full_name and have rails match the
first_name and last_name fields?
I currently receive this error when I try, because full_name
2007 Nov 06
2
Why is this view spec failing?
I can''t figure out why I am getting a failure. It renders out fine in
the browser.
<h1>New member</h1>
<%= error_messages_for :member %>
<% form_for(:member, :url => members_path) do |f| %>
<fieldset>
<legend>Member Info</legend>
<p><label for="member[first_name]">First Name:</label> <%=