Detecting whether a request comes from render_component


#1

Hi All,

Anyone know if there is a way to detect whether a request came from a
render_component call? There isn’t anything obvious from looking at the
source, but it would be useful as I have set up a logging filter in my
application.rb, and I’d prefer to exclude all component renders, since
they just add extra lines to my log (I guess I could exclude identical
rows at the db level).

I’m thinking of something like the xhr? method that allows a controller
to check whether a request came from an ajax submission.

I was guessing that the same check that catches the double_render error
might be used, but the check it uses (performed?) is a private method. I
guess I could try re-rendering the same controller/action and test
whether it leads to a DoubleRender error, but I imagine that would be
expensive.

Ideally some kind of :component => true element/value in the options
would be cool …

CHEERS> SAM


#2

I never found a built in solution like xhr? to do this with. I always
just added a params flag and checked for that in the action:

render_component :controller => ‘foo’, :Action => ‘bar’, :component
=> true

The you can check for params[:component] and act accordingly.

-Ezra

On Feb 1, 2006, at 8:37 AM, Sam J. wrote:

I’m thinking of something like the xhr? method that allows a

Ideally some kind of :component => true element/value in the options
would be cool …

CHEERS> SAM


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails

-Ezra Z.
WebMaster
Yakima Herald-Republic Newspaper
removed_email_address@domain.invalid
509-577-7732