Displaying 20 results from an estimated 10000 matches similar to: "Agile book - getting confusing error"
2006 Apr 03
7
Getters and setters problem?
Hi list,
first evening of playing with rails, so please forgive me if I ask
something stupid. ;-)
I created a User model and tried to use ActiveRecord callbacks to
convert the password to sha1 just before saving it. For some reason
postgresql gives me a error because the given password is null. To
test even further I tried to change :login too, same error happens,
:login is empty too.
I am sure
2006 Jun 05
2
When adding a record in console, a parameter comes in as null even when I set it
In console, I am trying to create a User but the :account_id does not come
in. Console just gives me back :account_id => nil. Obviously I''m trying to
set it though. Silly console...
But, I can set the account_id column in my controller like so:
@user = User.new(params[:user])
@user.account_id = account.id
@user.save
Here''s what I give to the controller:
User.create :name
2005 Dec 17
1
lost in an ActiveRecord::StatementInvalid
I have an error I don''t know how to debug. I am adding the login
suport in Depot (the example in the RoR book) and
LoginController#add_user throws ActiveRecord::StatementInvalid in an
innocent /login/add_user GET request.
The trace goes down to a call to SQLiteAdapter#table_structure, and
the source code suggests what''s happening is that "PRAGMA
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 Apr 28
7
a simple problem but difficult
how can i access to a collection that was created in the same control
and the data that a want to access isn?t the id
the collection has : id, usuario, comandancia
comandancia is the data to access
the question is how to access comandancia in @acceso
this code is wrong :
def new
@catelemento = Catelemento.new
@acceso= Catacceso.find(:all,
:conditions
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 Mar 29
5
How to skip password validation when updating other fields?
Besides the hashed password, which is saved to db, I have two
password-attributes in my User model:
attr_accessor :password, :password_confirmation
I have validations on these attributes, and I need them to work both on
create and update, since I have pages for changing and resetting the
password.
Now when I want to update just the user''s login name, I guess I have the
next
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:
2007 Dec 31
1
Agile Web Dev w/Rails - Password Change
Happy New Year everyone.
Just wondering if anyone has coded the ability to allow a user to change
their password following the way the book (second edition) implements
administration.
Seems like I should be able to cut out the
password/password_confirmation portion of ''add_user'' form to create a
''change_pass'' form. The problem is I''m not sure how to go
2006 Jul 17
19
updating model
hello,
i am writing a simple user login system.
when registering a user account, i have two field:
password
password_confirmation
which are validated using
validates_presence_of
validates_confirmation_of
and these are then used to generate a password hash which is stored in
my database
when i want to update the record (without changing the password and
entering new values for password and
2006 Jun 16
2
Problem with User Login from Agile Web Development
I am trying to use an expanded version of the User Login from the Agile
Web Development with Rails book. It takes the user name and password
but then says "Invalid user/password combination". Looking at the log
everything seems to be fine until it sends the query to MySQL. The
query shows that the name is '''' instead of the name that was passed to
the self.login
2005 Dec 29
7
belongs_to causing NoMethodError exceptions ... ?
I''ve got a really strange problem using belongs_to. I apologize in
advance for the length... this is going to take a while to explain.
Basic idea: Creating a User requires that the user enter an email
address and activation key that matches an existing PendingUser.
After creating the user successfully, that pending user should be
marked as "used".
The problem:
When I
2006 Aug 07
2
NoMethod Error: Modifying Location of support modules
I''m trying to follow along with the Agile Development with Ruby on Rails
book and have encountered a problem with code having the following
syntax (partial class provided):
require "digest/sha1"
class User < ActiveRecord::Base
private
def self.hash_password(password)
Digest:SHA1.hexdigest(password)
end
end
I''m getting an error as:
undefined method
2007 Nov 17
18
Syntax Problem
I admit I am stuck. I am converting a legacy php site to ROR. The old
site uses MD5, a security flaw waiting to happen. I upgraded to AAA
and am adding code in the session_controller.rb file to see if
crypted_password is blank. If it is, crypt and check the password
against the old md5 version and write it in the new crypted_password
field.
Here is my code add on before the logged_in?:
def
2005 Jul 13
0
Testing failing
So I''m trying to be a good agile programmer and write unit tests for
my objects, but I''ve got a test I just can''t keep from failing.
I have a profile object that I just added username and
hashed_password to. I used the method in the Rails book to handle
hashing the password. My code is strait out of the book. The whole
object is at the end of this email.
I want
2008 Jan 17
6
how to control self.method access
i think self.method just like class method,so if i want to define it
as a private method,i should use
private_class_method :my_method
but i found follow code in < <Agile Web Development with Rails>>
private
def self.hash_password(password)
Digest::SHA1.hexdigest(password)
end
just a mistake or there have some thing which i cannot get?
2005 Apr 23
7
Validation question
Hi all,
Is there a way to invoke validations at times other than save, create
and update? I know that I can do this by writing my own validation
checks using errors.add_[blah], but I''d like to leverage the existing
validation code.
What I have is two sets of fields in a record, set A and set B. Both
sets must be validated on record create. However, the trouble is that
after
2006 Jul 19
6
ActiveRecord::RecordNotSaved - bizarre behaviour.
Hi. I get a RecordNotSaved exception when trying to create a user record.
The error:
User Columns (0.005930) SHOW FIELDS FROM users
SQL (0.000465) BEGIN
SQL (0.000466) COMMIT
ActiveRecord::RecordNotSaved (ActiveRecord::RecordNotSaved):
...
As you can see, there''s no INSERT SQL generated, which is the root cause
of the problem.
In my user model, I have the following
2005 Oct 14
1
Diff between attr_accessible and attr_accessor
I''m going though the paper back edition of agile development with Rails. On
page #128 I encountered following lines of code:
attr_accessor :password
attr_accessible :name,:password
What''s the difference between attr_accessor and attr_accessible?
-=- Neeraj
_______________________________________________
Rails mailing list
2007 Jan 26
7
How to protect attributes from being updated?
Hi!
I''m new to Rails!
Rails rox!
1 quesion so far:
I have :email attribute in User model.
I dont'' want :email to allow to be updated.
How do i do this with Rails?
Do I have to implement required validation manually?
Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: