[Rails-core] AssociationProxy#method_missing now yields?

2008-09-02 Thread Christopher J. Bottaro
Hello, Why does it call send with a block which yields instead of just passing the block to send directly (like it used to)? # new way def method_missing(method, *args) if load_target if block_given? @target.send(method, *args) { |*block_args|

[Rails-core] Re: protect_from_forgery(secret) and config.action_controller.session_store

2008-09-02 Thread Tim Haines
This patch (or one like it) also has the side benefit of being able to simplify the generated code for ActionController. The :secret could be uncommented by default, and the comment on the line above could be removed. On Wed, Sep 3, 2008 at 12:29 AM, Tim Haines <[EMAIL PROTECTED]> wrote: > I dec

[Rails-core] Re: ActiveRecord::AttributeMethods #respond_to?

2008-09-02 Thread James Rosen
No, sorry. I'm trying to _truly_ make an attribute private. I want nobody but my instance (self) to be able to access this attribute. There's nothing like attr_private to my knowledge, though, so I declared private methods. The problem is the basic order of the way ActiveRecord redefines :respo

[Rails-core] Re: ActiveRecord::AttributeMethods #respond_to?

2008-09-02 Thread Damian Janowski
On Tue, Sep 2, 2008 at 4:07 PM, James Rosen <[EMAIL PROTECTED]> wrote: > > Ok, but what about > > $ irb > irb(main):001:0> class Foo > irb(main):002:1> def bar > irb(main):003:2> end > irb(main):004:1> private:bar > irb(main):005:1> end > => Foo > irb(main):006:0> Foo.new.respond_to? :bar > => fal

[Rails-core] Re: ActiveRecord::AttributeMethods #respond_to?

2008-09-02 Thread James Rosen
Ok, but what about $ irb irb(main):001:0> class Foo irb(main):002:1> def bar irb(main):003:2> end irb(main):004:1> private:bar irb(main):005:1> end => Foo irb(main):006:0> Foo.new.respond_to? :bar => false -Gaius On Tue, Sep 2, 2008 at 2:21 PM, Damian Janowski <[EMAIL PROTECTED]> wrote: > > On

[Rails-core] Re: ActiveRecord::AttributeMethods #respond_to?

2008-09-02 Thread Jim Lindley
> class Foo < ActiveRecord::Base > > private > > # really protect attribute bar > def bar >read_attribute :bar > end > def bar=(val) >write_attribute :bar, val > end > > end > > Now Foo.new.respond_to?(:bar) really _should_ return false respond_to? is a Ruby core object method, it's

[Rails-core] Re: ActiveRecord::AttributeMethods #respond_to?

2008-09-02 Thread Damian Janowski
On Tue, Sep 2, 2008 at 3:00 PM, Jonathan Weiss <[EMAIL PROTECTED]> wrote: >> This is because the definition of :respond_to? checks >> whether @attributes.include?(method_name), but doesn't take attribute >> protection into account. >> > > It doesn't check attributes, it checks the actual methods o

[Rails-core] Re: ActiveRecord::AttributeMethods #respond_to?

2008-09-02 Thread James Rosen
It _is_ a core Ruby object, with a contract defined in Object. The problem is that Rails overrides that definition, accounting for ActiveRecord attributes. (It _should_ override, since it overrides method_missing.) All I'm saying is that the override devined in ActiveRecord::AttributeMethods is

[Rails-core] Re: ActiveRecord::AttributeMethods #respond_to?

2008-09-02 Thread Jonathan Weiss
> I would think that Foo.new.respond_to?(:bar) would be false, but it > returns true. It should be true as the Foo instance responds to a method called bar. > This is because the definition of :respond_to? checks > whether @attributes.include?(method_name), but doesn't take attribute > protectio

[Rails-core] Re: ActiveRecord::AttributeMethods #respond_to?

2008-09-02 Thread James Rosen
Sorry, you're right. I phrased my question wrong. Let's try this: class Foo < ActiveRecord::Base private # really protect attribute bar def bar read_attribute :bar end def bar=(val) write_attribute :bar, val end end Now Foo.new.respond_to?(:bar) really _should_ return fa

[Rails-core] ActiveRecord::AttributeMethods #respond_to?

2008-09-02 Thread Gaius
I have a model class class Foo < ActiveRecord::Base attr_protected :bar end I would think that Foo.new.respond_to?(:bar) would be false, but it returns true. This is because the definition of :respond_to? checks whether @attributes.include?(method_name), but doesn't take attribute protection

[Rails-core] Re: Hash#slice!

2008-09-02 Thread Michael Koziarski
On Mon, Sep 1, 2008 at 2:14 PM, 7rans <[EMAIL PROTECTED]> wrote: > > Hi, > > One of the fundamental methods share by both ActiveSupport and Facets > is > Hash#slice!. A few days ago, someone pointed out to me that the two > libs > in this case are not quite the same. Quote, "I got hosed by a lovel

[Rails-core] Hash#slice!

2008-09-02 Thread 7rans
Hi, One of the fundamental methods share by both ActiveSupport and Facets is Hash#slice!. A few days ago, someone pointed out to me that the two libs in this case are not quite the same. Quote, "I got hosed by a lovely bug stemming from facets' and rails' slice! returning opposite things... facet

[Rails-core] Re: protect_from_forgery(secret) and config.action_controller.session_store

2008-09-02 Thread Tim Haines
I decided to have a go at this tonight. Patch attached at http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/957 I'm happy to hear any feedback on the patch - as it might have a broader impact than I'm aware of with my limited experience hacking on rails source. Cheers, Tim. On

[Rails-core] Re: collection << on new_record? == false (hm:t) can be deferred?

2008-09-02 Thread Michael Koziarski
> Would be a patch useful, if currently there are no ways, regarding > this matter? It sucks that this is inconsistent, but I think this is probably going to be a pretty tough problem for you to solve with a patch. Because the presence of an object in the has_many :through collection requires th

[Rails-core] Re: protect_from_forgery(secret) and config.action_controller.session_store

2008-09-02 Thread Tim Haines
Cheers Koz, I might have a poke around with it over the weekend and see if I can come up with anything useful. Tim. On Tue, Sep 2, 2008 at 7:11 PM, Michael Koziarski <[EMAIL PROTECTED]>wrote: > > > I'm wondering if the secret param should ever be used when using the > cookie > > session store?

[Rails-core] Re: protect_from_forgery(secret) and config.action_controller.session_store

2008-09-02 Thread Michael Koziarski
> I'm wondering if the secret param should ever be used when using the cookie > session store? If not, should rails raise an error when configured with the > cookie store and secret param? Ideally yes, rails would raise an error when misconfigured like this. I believe at present the presence or