Displaying 20 results from an estimated 34 matches for "find_by_email".
2011 Sep 22
2
find_by_email dynamic method returning new
Hello everyone,
I have a rails app which uses email as login name. At some point, I
have to search the user, in the User model by email. For some reason,
the method User.find_by_email(email) returns nil, even though the user
is in the database.
The same applies for any find_by_* method that searches by any
database column. I was able to find the user using the User.find
Does anyone have an idea of what might be going on?
thanks,
-fred
--
You received this message because yo...
2010 Nov 28
2
Dynamic find_by method returning nil in a class method
...> true,
:length => {:within => 6..20},
:confirmation => true
validates :sex, :presence => true
validates :birth_date, :presence => true
def self.authenticate(email, submitted_password)
user = find_by_email(email)
puts user
return nil if user.nil?
return user if user.has_password?(submitted_password)
end
end
as you can see I left out some code but the problem I am having is
where you can see that I have a "puts user". when running this method
from the Console like so
User.au...
2012 Sep 20
4
access controller's object attributes in view page
...that admin object to the admin''s view page to
get the name of the admin. But when I try to access the name it is
showing error as "undefined method `name'' for :current_admin:Symbol"..
Please help..
Please find my code below
Sessions Controller
def create
admin=Admin.find_by_email(params[:session][:email].downcase)
if admin && admin.authenticate(params[:session][:password])
redirect_to(admins_index_path(:current_admin=>admin))
end
end
In view page of index_admin
<%="Hi"%><%=params[:current_admin.name]%>
--
Posted via http:...
2011 May 06
3
Why returns nil?
Hi everyone, I''d like some help to understand this method:
def self.authenticate(email, submitted_password)
user = find_by_email(email)
return nil if user.nil?
return user if user.has_password?(submitted_password)
# Don''t understand why it doesn''t return user instead of nil
# since ''user = find_by_email(email)'' was the last evaluated expression
end
like the comment, I ju...
2012 Feb 03
10
ruby on rails 3 tutorial book chapter9 Signin Failure
Hi I have problem trying to pass the signin failure test.
This is the test code of the sessions_controller.rb
def create
user = User.authenticate(params[:session][:email],
params[:session][:password])
if user.nil?
flash.now[:error] = "Invalid email/password combination."
@title = "Sign in"
render
2006 Mar 14
4
Two Customer Types - Best Design Principle?
...s have an existing
record, is there an elegant way to "merge" the extended details from the
form with the existing email address marked record on the database?
Currently I have the code:
form = params[:new_customer]
email = form[:email]
tmp_customer = Customer.find_by_email(email)
if tmp_customer != nil && (tmp_customer.level == ''mailinglist''
|| tmp_customer.level == ''test'')
@customer = Customer.new(params[:new_customer])
@customer.id = tmp_customer.id
@customer.level = ''...
2006 Jun 07
0
Refreshing remote :through associations with deletes
...from a remote database every
10 minutes. I''m using a :through association to relate people to
mailinglists through subscriptions.
# Works fine, every 10 minutes:
remote_lists.each { |list| List.find_or_create_by_name(list.name) }
remote_subscribers.each do |subscriber|
person = Person.find_by_email(subscriber.user)
unless person.nil?
Subscription.find_or_create_by_person_id_and_mailinglist_id(person.id,
local_list.id)
end
end
remote_lists.each do |list|
local_list = Mailinglist.find_or_create_by_name(list.list)
subscribers =
MailinglistSubscriptionRemote.find_all_by_list_subscrib...
2010 Feb 08
0
recommending friends, using RoR's Mailer
Hi there, I wan tto be able to allow users to invite friends...
The action below is exactly the same as the code used to send a user
their username. Only difference is, I need to change the ''''user =
User.find_by_email(email)'''' part as obviously, I dont want to only
email people who are already on the site.
def invite
@title = "Invitation"
if param_posted?(:user)
email = params[:user][:email]
user = User.find_by_email(email)
if user...
2006 Nov 09
2
help with join tables and has_and_belongs_to_many
...:privileges_users do |t|
t.column :user_id, :integer, :null => false
t.column :privilege_id, :integer, :null =>false
end
admin_priv = Privilege.find_by_name(''admin'')
user_priv = Privilege.find_by_name(''user'')
admin_user = User.find_by_email(''admin-7Ts6kVb0ZJk@public.gmane.org'')
admin_user.privileges << admin_priv
admin_user.privileges << user_priv
anon_user = User.find_by_email(''anon-7Ts6kVb0ZJk@public.gmane.org'')
anon_user.privileges << user_priv # BOMB HERE
e...
2008 Jan 08
1
howto rebuild a object from a received xml hash structure ?
im my web server app , i have an action to be used as a REST web
service
# GET /user/membership.xml?email=emailaddress
def membership
@user = User.find_by_email(params[:email])
respond_to do |format|
format.xml { render :xml => @user.to_xml( :only =>
[ :first_name, :last_name, :display_name, :membership_type, :membership_at], :skip_types
=> true)}
end
end
my client web app get it :
@referee = Referee.new(params[:referee])...
2007 Nov 25
2
Rails sessions in plain text stories
...9;'m being particularly thick, but I''ve been trying to find
the solution to this for a couple of hours now and I just can''t seem
to be able to do it...
I''m trying to write a step as such:
Given("user $email is logged in") do |email|
user = User.find_by_email(email)
session[:user_id] = user.id
end
This is the way it would look in specs... but all I seem to be
getting, depending on whether I write it as @session,
@controller.session, session, request.session, @request.session,
etc... is errors like:
NoMethodError: You have a nil obje...
2005 Dec 12
2
How to use arbitrary relationships in Activerecord
How can I ask ActiveRecord to make it''s "has_many" code to work on some
arbitrary relationship between two tables? ie neither field is a primary key
The situation is that I am writing a Postfix management application and
one of the tables to manage is the "alias" table. My primary key in the
"mailbox" table is "id", but the alias table is just
2012 May 12
12
before_save messing up
....
.
.
.
private
def create_remember_token
self.remember_token = SecureRandom.urlsafe_base64
end
end
#sessions_controller.rb -------> Sessions Controller
class SessionsController < ApplicationController
def new
end
def create
user = User.find_by_email(params[:session][:email])
if user && user.authenticate(params[:session][:password])
sign_in user
redirect_to user
else
flash.now[''error''] = ''Invalid email/password combination''
render :new
end
end
def destroy
en...
2013 Sep 26
2
Login Problem
...lter :require_no_authentication, :only => [ :new, :create ]
prepend_before_filter :allow_params_authentication!, :only => :create
prepend_before_filter { request.env["devise.skip_timeout"] = true }
skip_before_filter :verify_authenticity_token
def create
user_email = User.find_by_email(resource_params[''email''])
if user_email
if server_emails.include?(resource_params[''email'']) ||
params[:client_login] != nil
if user_email.valid_password?(resource_params[''password''])
if (user_email.status == &qu...
2009 Feb 08
2
SocketError in EmailController#correspond
...ler
layout "site"
include ApplicationHelper
include ProfileHelper
before_filter :protect, :only => [ "correspond" ]
def remind
@title = "Mail me my login information"
if param_posted?(:user)
email = params[:user][:email]
user = User.find_by_email(email)
if user
UserMailer.deliver_reminder(user)
flash[:notice] = "Login information was sent."
redirect_to :action => "index", :controller => "site"
else
flash[:notice] = "There is no user with that email address....
2008 Feb 07
1
ActiveRecord 'find_or_initialize_by' dynamic finder bug? Ignoring conditions.
...ce I
could use ''find_or_initialize_by_name_and_state()'' however what I am
really trying to show is that the :conditions options are ignored.
Check out the actual SQL run by each of these finds in a console to
see what I mean.
## EXAMPLE : USES CONDITIONS ##
>> @user = User.find_by_email(''foo-+RB1Aph5k6s@public.gmane.org'', :conditions => {:state => ''passive''})
User Load (0.000426) SELECT * FROM `users` WHERE (`users`.`email`
= ''foo-+RB1Aph5k6s@public.gmane.org'') AND (`users`.`state` = ''passive'') LIMIT...
2006 Aug 09
0
association dows not grt foreign key
...---------------------
end
class Address < ActiveRecord::Base
belongs_to :person
end
----------------------------------
person = Person.new
person.email = "bruce@tate.com"
address = Address.new
address.city = "Austin"
person.address = address
person.save
person2 = Person.find_by_email "bruce@tate.com"
person2.address.city
=> "Austin"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060809/e9a454fb/attachment.html
2006 Aug 09
0
Re: association does not get foreign key
...se
> belongs_to :person
> end
>
> ----------------------------------
>
> person = Person.new
>
> person.email = "bruce@tate.com"
> address = Address.new
> address.city = "Austin"
> person.address = address
> person.save
> person2 = Person.find_by_email "bruce@tate.com"
> person2.address.city
> => "Austin"
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060809/88e6382a/attachment.html
2006 Feb 08
1
testing with loginengine and userengine
Hi all,
My unit tests and functional tests are failing because my tests aren''t
authenticated. I''m using using user engine and login engine.
How can I fake authentication to make my tests work properly.
Thanks,
Jason Edgecombe
2006 Jan 30
1
Either/Or Validation
How would I use validations to ensure I either received a blank value or
a ten digit number?
If I set validates_length_of :field, :in => 0..10 then that would allow
any value in-between. The allow_nil => true option does not seem to
work.
I''ve also tried using this with some combination of
validates_numericality_of but cannot get it to work.
Any help would be greatly