Displaying 20 results from an estimated 30000 matches similar to: "ActiveRecord callback chain exception?"
2013 Oct 25
6
Migrate postgresql database to uuid
Hi all,
I am using rails 3.1 and ruby 1.9.3,Now i want to use uuid concept in
rails 3 for existing data
so i did like :-
create_table :posts, :id => false do |t|
t.string :uuid, :limit => 36, :primary => true
end
ActiveRecord::Base.class_eval do
# old rails versions
set_primary_key ''uuid''
before_create :generate_uuid
def generate_uuid
self.id =
2009 Dec 03
1
Ann: ArEvents
Hi,
I needed to be able to add actions to be taken during the lifecycle of
ActiveRecord object, but needed to configure it dynamically.
Observers were not flexible enough and I ended up developing ArEvents,
which lets you easily attach and detach event listeners, the events
correspond to the active record callbacks.
If you have an existing model, just include the ArEvents module:
2006 Feb 21
2
ActiveRecord before_ callbacks question
Hi!
I need to set the primary key in a model and postgres table to something
different than id. View Edit and such works in the scaffolded
controller. However if I click in the controller below the list of data
onto New then I get an error message like this:
Showing app/views/admin/_form.rhtml where line #5 raised:
undefined method `nr_before_type_cast'' for
2007 Mar 17
4
Created_on and updated_on in a non-ActiveRecord model
Hi you all,
I have a model simulating an ActiveRecord model, according to the tips
stated in [1]. It is simulated because even though I am gonna save the
attributes in a file, not in a DB, I still want the validations made by
ActiveRecord::Base (see code below).
Well, the thing is that I also want the behaviour of the created_on and
updated_on columns, that get modified automatically before
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
2011 Jun 27
2
insert value of primary key into another field before record is saved
Hey all,
I created a seed task:
def books!
books = Book.where(:type_id =>
Type.find_by_name(''Fiction'')).order(''id'')
books.each do |book|
@books = 4.times.map do |i|
subbook! "#{book.book_num}-#{i}".to_s, :book_state =>
BookState[:available].id, :book => book
end
end
puts "log it:
2012 May 26
2
before_create is after_validatation :on => :create , when it should be before_validation :on => :create
In ActiveRecord''s callbacks, methods within a before_create callback
are called after the validation, but before the model is created.
This was an intentional design decision, but I think it was the wrong
one. What do you think?
When I think of before_create, I think of before_validation :foo, :on
=> :create, but, by default, before_create is synonymous with
after_validation :foo,
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
2005 Oct 25
1
initialising an instance variable on ActiveRecord creation
Hallo, I have a table like this:
create table properties(
id bigint unsigned not null auto_increment,
property_variable_stack_id bigint unsigned not null,
primary key(id),
foreign key (property_variable_stack_id) references
property_variable_stacks (id))
type=InnoDB;
Here you can see a reference to a table property_variable_stacks.
>From outside the Property class I can set up a Property with
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
2007 Jan 08
2
before_create firing twice on a save - RC2
I have a unit test which fails using Rails 1.2RC2, because a method marked
by the before_create filter is firing twice when my ActiveRecord is saved.
Is a before_create filter supposed to cause multiple invocations? We have
assumed it is called once, and only once, when the object is created, in our
code (but we unit tested it to make certain).
This is one of three issues I have with my unit
2005 Jul 26
3
Generating unique random tokens for ActiveRecord objects
I have an ActiveRecord subclass that needs to generate a random (hard
to guess) token for each record in its corresponding table. Currently
I''m doing something like this:
def before_create
self[''token''] = random_value
while self.class.find_by_token(self[''token''])
self[''token''] = random_value
2013 Aug 30
3
frozen? is defined by ActiveRecord
Hello folks
I got that error Pls tell me what''s wrong
frozen? is defined by ActiveRecord
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this
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''
2012 Nov 18
3
remarkable activerecord association RSpec
i''m using gem Remarkable activerecord for association. i''ve installed
remarkable and remarkable activerecrod both gem. i''ve added both gem in
my Gemfile. i''ve added "remarkable_activerecord" as required in
spec_helper.rb.
describe Authentication do
FactoryGirl.build(:authentication).should
belong_to(:user)
2006 Sep 09
2
why doesn't this work (setting attribute in "before_create")
Hi,
Can anyone spot why the below doesn''t work?
* I have a "created_by" column in my create table in the dB
* I have a "before_create" line, which definitely gets called
* I tried a few different ways to set the "created_by" attribute in the
model but it doesn''t seem to work, i.e. doesn''t appear in the database
2013 Feb 18
6
How to clear ActiveRecord query cache on associations with dynamic table
In part of my application I''m using dynamic tables. I''m aware of the single
thread conditions. I''ve tackled some caveats yet - will post a blog about
it soon - but there''s one I need help with.
Consider 2 models that are associated: Order and OrderLine where Order has
many order_lines.
Now we set the table names for them:
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`,
2012 Aug 24
3
ActiveRecord storing arrays and hashes
Hi,
When trying to store a Array or Hash to a string field, ActiveRecord
automatically
serializes them to yaml. If that''s so why is there a special option
called serialize?
--
Azhagu Selvan
http://tamizhgeek.in
--
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
2012 Dec 06
2
Bye Bye, Observers
Observers will be no more as of Rails 4, farewell, never been much of a
fan. However, I''m using it in one of my gems which enables model attributes
for use with a WYSIWYM editor. The resulting markup is persisted, but in
order to use it in a view, it has to be nokogiried in a helper which
fragment caches the result. This cache has to be zapped once the model
instance is either