Displaying 20 results from an estimated 6000 matches similar to: "Encrypting data before saving"
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 May 24
1
Observer behavior differences between DEV and TEST environments ?
Hi all !
I''m having an issue and I can''t seem to make heads or tails of it.
I am attempting to add an observer to a model object. I created
app/models/greenback_transaction_observer.rb, inherited from
AR::Observer, defined methods, registered in config/environment.rb,
but things don''t work...
So, I took a step back and put in the following code:
class
2012 Nov 10
6
Suggestion: `before_save on: :create` should either work or raise an exception
There''s a small inconsistency in ActiveRecord''s callback syntax that has
tripped me up before. It wouldn''t be a big deal, but it can lead to a
silent failure. I''d like to suggest that it either be made consistent or be
made to fail loudly.
The issue is that to do something before validating, but only when
creating, you use `before_validation on: :create`,
2006 May 15
1
encrypting databases
Hi all, your thoughts appreciated:
I''d like to encrypt one of my databases, as described in the first Rails book,
by putting encrypt and decrypt methods on the :after_find, :before_save, and
:after_save hooks in my model (what a lovely transparent way rails does
things!). But unlike the book, I actually want to use real encryption, perhaps
something from the OpenSSL library, something
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 Jun 29
3
Working around/with Restful Authentication
I''m using Restful Authentication, and the code to create a user is
pretty straight forward - there is a before_save action and a
before_create action:
before_save :encrypt_password
before_create :make_activation_code
But for some reason when I try to create a user programmatically in
the controller like this:
User.new(:email =>
2006 Apr 21
2
Using before_create and conflicting setter method...
Hi,
I am having trouble using before_create when I have an specialized
setter method:
before_save :set_campaign_start
#-----------------------------------------------------------------------
-------
def set_campaign_start
self.campaign_start = Time.now
end
# We want the date to always start at midnight
2008 Mar 18
0
Major issues with ActiveRecord callbacks in BackgroundRb r324
Hi there
I''ve been running BackgroundRb in production for a few months now. Recently
we added encryption onto some of our ActiveRecord fields by hooking in the
before_save and after_save callbacks, like:
class MyCallback
def initialize(attr_names)
@attr_names = attr_names
end
def before_save(model)
@attr_names.each do |attr_name|
next if
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
2006 Jul 16
0
Problems with validates_lenght_of
I''m building a login system, and I want users to be able to update their
password, first name and last name after signing up. So, when signing up
password can''t be nil, and it must be between 6..20 characters long. However,
on update, the user can choose to leave the password field empty (but fill in
other stuff, like first name) and then I want the User model to not update
2006 Feb 15
8
Agile book - getting confusing error
Working through the beginning phase from the Agile book on
''Administration''
undefined method `hashed_password='' for #<User:0xb7911324>
...
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1498:in `method_missing''
#{RAILS_ROOT}/app/models/user.rb:12:in `before_create''
2006 Apr 21
2
destory Test Case Messes up all tests
I am trying to create unit tests for my users model but when I add a
test that destroys a user, that user is not available in any of the
other test. If I remove the test that destroys the user all my other
tests work again.
All the fixtures are suppose be reloaded between tests right?
Here is my testcase :
require File.dirname(__FILE__) + ''/../test_helper''
class UserTest
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
2008 Mar 11
6
saving an ActiveRecord without trigging the callbacks
Hello,
How can I save an ActiveRecord without trigger before_save,
after_save, etc?
Thanks for the help.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group,
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 Jan 09
0
Saving or updating multiple models
Hello all,
I was wondering how one would create multiple models in one controller action.
Consider the following models:
class Worker < ActiveRecord::Base
belongs_to :person
belongs_to :user
validates_presence_of :person_id
end
class Person < ActiveRecord::Base
has_many :workers
end
class Client < ActiveRecord::Base
has_many :workers
end
class User <
2010 Aug 18
11
When after_save isn't after the save....
I have a Production model, which represents a farmer''s crop. After
create (via after_save) I call a method that creates one or more
Supply models, which represent a week of anticipated product harvest.
After each of those are created, a class method gets called that tries
to match each new Supply with outstanding orders for the same time
period. If a match is made, a transaction (an
2006 Jul 06
0
updating model bypasses callbacks
Hi,
Very quickly, I''m having trouble calling my before_save ro before_update
callbacks when I do something like User.update(id, params["user"]). I
notice that Rails is calling after_save but for some reason it doesn''t
call the before_save or before_update callbacks. Any thoughts would be
appreciated.
Thanks.
--
Posted via http://www.ruby-forum.com/.
2006 Jul 20
0
Custom Rails Application Logging
I am trying to add custom logging to my rails app via a ''.rb'' module
file in the ''/lib'' directory and then call it from my models via
CallBacks (ie: before_save, after_save, etc).
It loads the module just fine in my class and the CallBack executes the
module''s code. However, my module (remember it''s in the ''/lib''
2006 Nov 19
1
ActiveRecord save-update not performed ?
I try to understand the following issue :
- when creating a new User record, I use an UserObserver to trap the
before_save call back and send an email
def after_create(user)
UserNotifier.deliver_signup_notification(user)
end
- Once created a user can ask for a password reset, which is also
trapped by the UserOberver
def after_save(user)
UserNotifier.deliver_reset_password(user) if