similar to: after_initialize and after_save

Displaying 20 results from an estimated 20000 matches similar to: "after_initialize and after_save"

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 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
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
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
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
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
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
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 Feb 13
4
activerecord << operator
Hello, I am new here and actually I am writing my first RoR app. My question is: -------- class Topic < ActiveRecord::Base has_many :messages end class Message < ActiveRecord::Base belongs_to :topic end class ForumController < ApplicationController def post message = Message.new(params[:message]) @topic = Topic.find(params[:id]) @topic.messages
2007 Jul 25
5
set_default_values rocket science - continuing after_initialize/after_find misfeature
Just starting a new thread so that it''s easy to follow. I just submitted a patch at trac to add a new class method called "set_default_values" ( not a great name I think ), which lets you do all kinds of crazy stuff with setting default values. This ticket is at http://dev.rubyonrails.org/ticket/9093 and example pastie is at http://pastie.caboo.se/81925 It also lets you make
2006 Nov 29
1
actionmailer on Debian Etch
Hello, I have two debian etch systems, both have rails. I have installed them with apt, not gems. No problems so far. Now I have tried to use the actionmailer. The results: mage@miranda:~/temp$ rails mailer create create app/controllers [....] create log/test.log mage@miranda:~/temp$ cd mailer mage@miranda:~/temp/mailer$ script/generate mailer Letter test send
2002 Jul 15
1
[Q] htb
Hi Can I make htb node (class) without rate limit For example limit ip1/len1 to xx kb limit ip2/len2 to yy kb any other traffic - without limit? -- Best regard, Alexander Trotsai aka MAGE-RIPE aka MAGE-UANIC My PGP at ftp://blackhole.adamant.net/pgp/trotsai.key[.asc] Big trouble - Your modem doesn''t speak English.
2007 Dec 12
2
possible bug in eager loading
Hello, @users = User.find(:all, :include => {:user_data => :user_data_field}, :order => "username = ''someone-oHC15RC7JGTNLxjTenLetw@public.gmane.org'' desc", :limit => 50) This produces: User Load IDs For Limited Eager Loading (74.648762) SELECT * FROM (SELECT DISTINCT ON (users.id) users.id, username AS alias_0 FROM users LEFT OUTER JOIN
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
2006 Aug 12
1
url_for and :defaults
Hello, in my routes there are (just for testing): map.connect '':controller/:id/:action'', :defaults => {:action => ''alma''} in my controller: def alma render :text => url_for(:id => 123) end so I go to: http://localhost:3000/music/store which generates: http://localhost:3000/music/store/123/index Where the
2006 Feb 11
5
after_(read|find) callback?
I am pondering the possibility of encrypting/decrypting some fields in a SQLite backend on-the-fly. The point of the message is not security, I know that''s broken, but whether there''s a technique that provides on-the-fly save/read filters. Of course the solution would need to work transparently in joins, so user.posts.last.title would do the right thing if title
2014 Feb 03
2
get current song
Hi, I use dynamic playlist, so do not have static list of files. I sream this play list on my mage via simple flash player, and show this playlist in this page with ajax-ed javascript. Here is question. I need to get current song, but when I ask icecast server I get wrong information. Sometimes song is still playing, but info from server is updated to next track. I have many short (3-5-10
2005 Aug 25
3
Active Record Object Dependency
I have three model objects: 1. Document 2. Section 3. Content According to my requirements a Document must have at least one Section. Similarly a Section must have at least one Content. How can I add a Section when a Document is created and add a Content when a Section is created? My code: class Document < ActiveRecord::Base has_many :sections end class Section < ActiveRecord::Base
2004 Mar 04
1
Domain Admin with tdbsam on 3.0.2a
Firstly I apologise for the length of this query but I am hoping that if I document everything I did someone might respond / be able to help. My Configuration is Samba 3.0.2a as a PDC on Redhat 8. I cannot for the life of me get the "Domain Admins" functionality to work I am hoping that another set of eyes can shed some light on this problem as I have now spent 41 hrs googling /
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/.