# Exempt\_from\_layout has no effect

**URL:** <https://www.ruby-forum.com/t/exempt-from-layout-has-no-effect/77752>\
**Category:** Rails\
**Created:** [November 30, 2006, 7:13am UTC](https://www.ruby-forum.com/t/exempt-from-layout-has-no-effect/77752 "2006-11-30T07:13:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [November 30, 2006, 7:13am UTC](https://www.ruby-forum.com/t/exempt-from-layout-has-no-effect/77752/1 "2006-11-30T07:13:53Z")

</div>

I am trying to experiment with a plugin that uses a .rjpg template to  
generate an image rendered by rmagick.

All seems well, but the file is rendering with application.rhtml layout  
around it. And considering the data is binary image data, this is  
obviously not what I want.

So I have this in my plugins init.rb:

ActionController::Base.exempt\_from\_layout ‘rjpg’

but it has no effect. I also tried using :rjpg and /.rjpg$/ to no  
avail. I tried putting the call to exempt\_from\_layout in my  
environment.rb, and in the controller that is calling this template, but  
no matter what it still renders with a layout.

The only way I can suppress the layout is explicitly telling the layout  
not to render inside my action:

def foo  
@image = Image.find(1)  
render :layout =\> false  
end

This seems like a silly requirement, especially since  
expempt\_from\_layout is supposed to work with edge/1.2. I have tested  
both version and cannot get the layout to be ignored for the render.

Anyone used exempt\_from\_layout successfully? What am I doing wrong  
here.

Thanks in advance,  
-Alex

* * *

> **[Beautiful Pixel](https://beautifulpixel.com)**
>
> A log of random code experiments and semi-useless thoughts from some software developer named Alex...

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [November 30, 2006, 7:17pm UTC](https://www.ruby-forum.com/t/exempt-from-layout-has-no-effect/77752/2 "2006-11-30T19:17:04Z")

</div>

Alex W. wrote:

> So I have this in my plugins init.rb:
> 
> ActionController::Base.exempt\_from\_layout ‘rjpg’
> 
> but it has no effect.

Bump.

I suppose I need to figure out how to create a test case for this and  
submit a ticket.

* * *

> **[Beautiful Pixel](https://beautifulpixel.com)**
>
> A log of random code experiments and semi-useless thoughts from some software developer named Alex...

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [November 30, 2006, 7:42pm UTC](https://www.ruby-forum.com/t/exempt-from-layout-has-no-effect/77752/3 "2006-11-30T19:42:54Z")

</div>

> Alex W. wrote:
> 
> > So I have this in my plugins init.rb:
> > 
> > ActionController::Base.exempt\_from\_layout ‘rjpg’

Tip: Go with PNG, for various technical and political reasons which I  
have  
not researched but am certain exist…

–  
Phlip  
[Redirecting...](http://www.greencheese.us/ZeekLand) ← NOT a blog!!!

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [November 30, 2006, 10:29pm UTC](https://www.ruby-forum.com/t/exempt-from-layout-has-no-effect/77752/4 "2006-11-30T22:29:47Z")

</div>

Since I am 90% sure this is a legitimate bug, I have created a ticket  
with a failing test. If anyone has any solutions for this problem,  
propose a patch and lets get this fixed!

[http://dev.rubyonrails.org/ticket/6742](http://dev.rubyonrails.org/ticket/6742)

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [November 30, 2006, 7:48pm UTC](https://www.ruby-forum.com/t/exempt-from-layout-has-no-effect/77752/5 "2006-11-30T19:48:43Z")

</div>

Phlip wrote:

> > Alex W. wrote:
> > 
> > > So I have this in my plugins init.rb:
> > > 
> > > ActionController::Base.exempt\_from\_layout ‘rjpg’
> 
> Tip: Go with PNG, for various technical and political reasons which I  
> have  
> not researched but am certain exist…
> 
> –  
> Phlip  
> [Redirecting...](http://www.greencheese.us/ZeekLand) ← NOT a blog!!!

PNGs are awesome. But they are either 8-bit and small in filesize, or  
they are full color and large in filesize. JPEG’s represent a good  
balance between filesize and image fidelity that PNG still can’t match  
for photographic data.

But this discussion is really outside the scope of my question here. I  
am simply trying to learn to write template handlers.
