Displaying 20 results from an estimated 400 matches similar to: "set_default_values rocket science - continuing after_initialize/after_find misfeature"
2006 Aug 11
1
after_initialize and after_save
Hello,
I am still reading Agile Web Developer pdf, it says about
after_initialize and after_find. There is a Joe asks part when I read
that they are special, however I didn''t really get the idea, why they are.
On rubyonrails.org in the manual there is some sort description about
their speciality, however their full descriptions are missing.
What are the difference between
2005 Nov 04
0
after_find callback in an acts_as plugin
Hi,
I am thinking about writing an acts_as_fox plugin that defines an
after_find callback method. If I do this what will happen if a user
creates a model that acts_as_fox but this model has it''s own
after_find callback method? I imagine that the model''s after_find
method shadows the plugin''s after_find. Presumably both after_find
callbacks would need to be performed but
2005 Dec 14
3
Migrations bug with Rails 1.0, PostgreSQL 8.1?
Filed a ticket for bogus Ruby produced via:
rake db_schema_dump
http://dev.rubyonrails.org/ticket/3232
I''d appreciate it if someone could verify against
PostgreSQL 8.0.x
--
-- Tom Mornini
2012 Dec 24
4
Bad idea to add/remove associations in after_find
I have 2 distinct types of users (artists and curators) in my system and
they currently share all associations (eg has_one :portfolio).
However, a curator shouldn''t have a portfolio so I would like to only
add that association when required. Obviously I could just return nil
for that method, but it doesn''t feel right having that there in the
first place.
What''s the best
2010 Jun 11
2
AR after_initialize quandry
I have a case where I am abstracting the creation of models. After a
fair bit of indirection, I eventually get around to making a .new call.
I need to be able to pass params to that .new call.
I know I can''t use def initialize() in an AR model (rather frustrating).
So, I have found some references to after_initialize, but that doesn''t
work either.
I see several threads on
2007 Jun 16
1
extending activerecord base with after_initialize
hi,
i am having problems getting after_initialize for activerecord
subclasses. basically, i am trying to use the guid plugin by andy
singleton. i am having problems extending the class to the plugins i
installed, so i figured i will just apply this to all the models in my
project. i trled to add the following to my lib/ folder. my goal is
to extended the activerecord class so that it uses
2010 Jan 12
1
Rails after_initialize block doesn't seem to be run in the backgroundrb context
Hi all,
Just had an interesting production failure while updating my Rails
application - a bunch of code previously in config/environment.rb was
put into config/initializers. That resulted in me having to wrap some
code in config/environments/production.rb into an after_initialize
do ... end block
When backgroundrb was run against that code, the setup done in that
after_initialize block
2006 Oct 27
5
Purpose of after_initialize in ActiveRecord?
All,
I have a quick question - is the purpose of implementing
after_initialize to allow custom attribute initialization for AR
descendants?
I have been overriding initialize whenever I require custom setup of my
model classes, like so:
def initialize(attributes = nil)
super
self.Status = ''G''
end
So I have a couple of questions:
1) Could I achieve the same
2008 Aug 24
2
config.after_initialize and development mode
Hi,
I''m using activemerchant and setting up a class variable using
config.after_initialize. It works great for the first request, but
then the variable is nil.
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
OrderTransaction.gateway =
ActiveMerchant::Billing::PaypalGateway.new(...)
end
I''m assuming this is is due to the model reloading after each
2006 Aug 09
7
function before_save
Hi everybody
I would like a function as the "before_save" method in the model. But it
must be the opposite. When I take out data from the database through the
model, I want to call a function before the data are available in the
controller.
Can anyone help me?
---- >>>> thx <<<< ----
--
Posted via http://www.ruby-forum.com/.
2006 Jun 21
3
[PLUG] new plugin, acts_as_modified
Nothing special, just my first plugin. it came out of a request I saw on
the list from someone who wanted to be able to tell if a model''s attributes
had changed prior to being saved. Well, this plugin does just that (at
least I hope it does).
http://rubyforge.org/projects/actsasmodified/
Please see the README for details. Constructive comments and criticisms are
appreciated.
Chris
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
2006 Jun 26
1
plugin, acts_as_modified 1.1.2
After a couple of thoughtful comments, I''ve made changes to
acts_as_modified plugin. It no longer relies on after_find and
after_initialize, which were both causing performance issues.
Please check it out and let me know what you think, where you might
recommend improvements or additional features and what not.
One feature I do have planned (again, thanks to comments), but
2006 Apr 06
1
Preventing data being written to the database on error
Hello,
How do I stop data being written to the database when an error occurs?
I have this in my controller:
if @item.valid?
#stuff here
else
render :action => ''show'', :id => @item
end
When it enters the else section, it renders the ''show'' action, but it
adds the data to the database. How do I prevent this from happening?
Thanks
--
Posted
2006 Jul 07
4
Calling a method each time an ActiveRecord Object is accessd
Hi,
I know that it is possible to execute code each time data is saved into
a model by using the +validate+ method.
However, is there also a way to execute code each time the data is
accessed, not just when it is changed?
Bye,
Winsmith
--
Posted via http://www.ruby-forum.com/.
2006 Jun 27
0
[UPDATE] acts_as_modified 1.1.3 now with tests (was Re: plugin, acts_as_modified 1.1.2)
Ask and ye shall receive.
1.1.3 now has a plugin test. i had one small issue with after_save
being called, so i added the callback in. it works when i create a
test app and run the unit tests so i think it has something to do with
how i override the save method. if you have any suggestions, please
feel free to comment.
As far as the AR test suite goes...I''m not sure how this plugin
2006 Apr 03
1
Why no call to Model.new on find?
I created a model with some internal state derived from a combination of
database and non-database data. Since I wanted to calculate these values
once rather than every time they''re requested by the view, I calculated
them in the initialize method and set some instance variables. However,
I soon noticed that these values weren''t getting set when I retrieved
data using the
2005 Nov 27
1
Comparing field's old value to new value
I want to expire caches if a certain field of an item changes. How can I compare the item field''s
old value to its new value (in the create, or after_save, etc. method)?
thanks
csn
__________________________________
Yahoo! Mail - PC Magazine Editors'' Choice 2005
http://mail.yahoo.com
2005 Jan 07
2
Asterisk 1.0.2 - Unable to allocate channel structure
Hi,
This morning I had some failed calls. On the console (and in the log)
I saw the error "Unable to allocate channel structure". Before I restarted
the process, I checked it's memory usage in ps and glanced at my free
memory in top. Asterisk was using a normal ammount of memory, about
40M. I don't think this was a system limit. This was running Asterisk
v1.0.2. Below is
2019 Sep 09
0
New Icecast Alternative: Rocket Streaming Audio Server
Hi all,
Long-time lurker, first time poster here. I've been using Icecast since
2006, but in recent years, I've kept running into all sorts of issues and
found many others who are in the same boat. I've done some small
experimental hacks to Icecast just for fun, but I've never contributed code
because:
1) I've been alienated by the Icecast team's hostility towards MP3 and