-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This seems like the reasonable and expected behavior. Many of my filters are reused as part of higher level DSL methods and my app would become unusable if Rails decided to begin ignoring my explicit instructions and refusing to run filters as I had asked for.

It is the programmer's responsibility to understand the inheritance and behavior of filters within their own app. Rails can't prevent you from tanking your own performance by asking for expensive filters more than once.

I don't see the need for a :uniq option, when you can use :only and :except on the before_filter and skip_before_filter flavors...

Maybe you are seeing deficiencies in your controller designs as flaws in the filter setup? Perhaps you just need to refactor your controllers and use skip and :only/:except more liberally?

On Jul 31, 2006, at 11:17 AM, Caio Chassot wrote:

Right now, filters run for as many times as you call, eg., before_filter.

If you do something like:

  5.times { before_filter :foo }

it might be expect, but I think the more common case of:

  @ ApplicationController
  before_filter :foo

  @ SubController
  before_filter :foo, :except => :bar

yields the unexpected result where :foo will run twice. (Luckly, for sub/bar it doesn't run at all, which is what I would expect)

I understand that in this particular case using skip_before_filter would fix it, but...

Do you really think it's a good idea to run filters more than once?

How about maybe adding a uniq option to pre/append_filter_to_chain, that would ensure a filter is never added twice (but related conditions may be changed)?

It would seem to me most filters that end up running twice or thrice do so harmlessly, but needlessly. At most, hindering performance.

_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iD8DBQFEziVgqvuZB2zXNU0RAkL/AJ9QfGDqcB3YTOYd0rVecPL0RDB4vACeIrWX
StIPZ1Shs8MekLhlugTZGjA=
=HHW8
-----END PGP SIGNATURE-----
_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to