Forum: Ruby on Rails detecting whether a request comes from render_component

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cb33b32bd5d675db7be148542976e510?d=identicon&s=25 Sam Joseph (Guest)
on 2006-02-01 17:39
(Received via mailing list)
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
8e44c65ac5b896da534ef2440121c953?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2006-02-01 19:16
(Received via mailing list)
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 Joseph 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
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

-Ezra Zygmuntowicz
WebMaster
Yakima Herald-Republic Newspaper
ezra@yakima-herald.com
509-577-7732
This topic is locked and can not be replied to.