[Rails-core] Extra documentation for ActiveSupport::CoreExtensions::String::Inflections

2006-05-09 Thread Manfred Stienstra
Hi All, Because of Josh Susser's post a while back about "ganging up on tests and docs" I figured it would be a good idea to start creating documentation for parts of Rails I found without documentation. http://dev.rubyonrails.org/ticket/5013 Can someone apply the patch? Manfred _

Re: [Rails-core] Extra documentation for ActiveSupport::CoreExtensions::String::Inflections

2006-05-09 Thread Kevin Clark
Manfred, In the future, please add the 'docs' keyword to documentation patches, it helps us get them processed more quickly. Thanks for the patch. Kev On 5/9/06, Manfred Stienstra <[EMAIL PROTECTED]> wrote: Hi All, Because of Josh Susser's post a while back about "ganging up on tests and docs"

[Rails-core] Circular dependency issue in startup

2006-05-09 Thread Francois Beausoleil
Hi all ! I am adding observers to some model objects. One of these uses RailsCron. RailsCron adds a class method to ActiveRecord::Base. Unfortunately, during the initialization phase, plugins aren't yet loaded, so I can't setup my observers in config/environment.rb, as suggested by the commen

[Rails-core] Issue in ActiveRecord generated reader methods

2006-05-09 Thread Jeff Hall
Hi all! I have come into a strange issue in Rails that I am hoping someone can shed some light. To make a very long story short, I have been researching how to override ActiveRecord::Base#read_attribute and write_attribute to perform security checks at the model level (influenced by the

Re: [Rails-core] Issue in ActiveRecord generated reader methods

2006-05-09 Thread Marcel Molina Jr.
On Tue, May 09, 2006 at 07:41:41PM -0500, Jeff Hall wrote: > ActiveRecord::Base#define_read_method(symbol, attr_name, column) > generates reader code for an attribute after Rails realizes there > should be a reader method for it, correct? But the generated reader > method body does not call

Re: [Rails-core] Issue in ActiveRecord generated reader methods

2006-05-09 Thread Jonathan Viney
I agree that seems odd. I can't see any reason not to use read_attribute there, as it will type cast if necessary. define_read_method could be simplified and Column#type_cast_code should be unnecesary perhaps. Currently, define_read_method uses @attributes.has_key? to verify that the attribut

Re: [Rails-core] Issue in ActiveRecord generated reader methods

2006-05-09 Thread Jeffrey Hall
Jonathan, Patch doesn't appear to break anything. All the unit tests run green. However, Marcel suggested that Stefan implemented this method intentionally for performance reasons. I will submit the patch as a Trac ticket - maybe then someone more skilled at benchmarking than I can see if any

Re: [Rails-core] Issue in ActiveRecord generated reader methods

2006-05-09 Thread Jonathan Viney
Sounds good. I can't see any obvious reason why the current implementation would be a lot faster than simply using read_attribute. I'll have a look at the ticket once you've posted it. -Jonathan. On 5/10/06, Jeffrey Hall <[EMAIL PROTECTED]> wrote: Jonathan, Patch doesn't appear to break anythi

Re: [Rails-core] Issue in ActiveRecord generated reader methods

2006-05-09 Thread Jeremy Kemper
On May 9, 2006, at 6:12 PM, Jonathan Viney wrote: I agree that seems odd. I can't see any reason not to use read_attribute there, as it will type cast if necessary. define_read_method could be simplified and Column#type_cast_code should be unnecesary perhaps. Inline type casting tailored to

Re: [Rails-core] Issue in ActiveRecord generated reader methods

2006-05-09 Thread Jeffrey Hall
> Inline type casting tailored to each attribute's column type is > faster than does-it-all read_attribute. It's for performance alone: Jeremy, This is a very good point. However, I am concerned about the origin of this whole discussion. Is it desirable that if the behavior of read_attribu

Re: [Rails-core] Issue in ActiveRecord generated reader methods

2006-05-09 Thread Jonathan Viney
So it simply puts the type casting code into the definition of each read method to avoid calling Column#type_cast_code each time the read is called? How much difference does that really make? Another solution to this may be to change read_attribute to use read_attribute_before_type_cast rather th

Re: [Rails-core] Issue in ActiveRecord generated reader methods

2006-05-09 Thread Jeffrey Hall
> That way you can simply override read_attribute_before_type_cast > and it will affect both read_attribute and the generated read_methods. > Thoughts? As I see it, the inconsistancy exists in one of two places. If typecasting as performed by read_attribute really impacts performance undesirbl

Re: [Rails-core] Issue in ActiveRecord generated reader methods

2006-05-09 Thread Jonathan Viney
Yeah, it is a bit inconsistant that the first call ends up executing different code than a subsequent call. method_missing should probably be changed to address this. But, I don't think that will solve your original problem of needing to be able to override the read methods ... ? -Jonathan. On

Re: [Rails-core] Issue in ActiveRecord generated reader methods

2006-05-09 Thread Jeffrey Hall
> But, I don't think that will solve your original problem of needing to > be able to override the read methods ... ? Haha - well as far as I can tell, my problem lies only in the fact that the two calls are different. My code works on the first reader call and breaks on any successive calls.

Re: [Rails-core] Issue in ActiveRecord generated reader methods

2006-05-09 Thread Stefan Kaes
Jeff Hall wrote: Hi all! I have come into a strange issue in Rails that I am hoping someone can shed some light. To make a very long story short, I have been researching how to override ActiveRecord::Base#read_attribute and write_attribute to perform security checks at the model level (infl

Re: [Rails-core] Issue in ActiveRecord generated reader methods

2006-05-09 Thread Jonathan Viney
For performance reasons, the generated read method does not use read_attribute, so I doubt that it will be changed. Changing both read_attribute and the generated read method to use read_attribute_before_type_cast gives you a single point where you can intercept all read methods and shouldn't hit

Re: [Rails-core] Issue in ActiveRecord generated reader methods

2006-05-09 Thread Jeffrey Hall
Thanks a bunch for all your input. If I have further issues, I'm sure that I will come running back! :) -- Jeff ___ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core