# Writing extensions - custom (non-scaffold) views

**URL:** <https://www.ruby-forum.com/t/writing-extensions-custom-non-scaffold-views/124888>\
**Category:** Radiant CMS\
**Created:** [January 3, 2008, 3:20pm UTC](https://www.ruby-forum.com/t/writing-extensions-custom-non-scaffold-views/124888 "2008-01-03T15:20:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jan\_Rietema](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ea924/32.png) [@Jan\_Rietema](https://www.ruby-forum.com/u/Jan_Rietema)\
**Post date:** [January 3, 2008, 3:20pm UTC](https://www.ruby-forum.com/t/writing-extensions-custom-non-scaffold-views/124888/1 "2008-01-03T15:20:50Z")

</div>

I’m currently writing my first proper extension and am having problems  
with custom views for the admin tab. I’m not using scaffold since the  
extension isn’t model-based.

I noticed a few things that struck me as awkward but that I could work  
around, including:

- not being able to use filters in my controllers (they are ignored)

- having to place my views in /app/views/admin/(extension\_name) rather  
than just /app/views/admin

Something I’m not getting to work is passing locals to the view or  
using references to instance variables. In all cases, I have a nil  
object rather than a reference to the objects the controller sees /  
instantiates.

Is this a known problem?

Regards,

Jan

---

<div class="post-metadata">

**Author:** ![Jan\_Rietema](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ea924/32.png) [@Jan\_Rietema](https://www.ruby-forum.com/u/Jan_Rietema)\
**Post date:** [January 3, 2008, 3:34pm UTC](https://www.ruby-forum.com/t/writing-extensions-custom-non-scaffold-views/124888/2 "2008-01-03T15:34:55Z")

</div>

Jan,

First, if your controller is public-facing (and not an admin tool), put  
this line at the top to disable the login requirement:

no\_login\_required

Second, your views should correspond to the _controller name_, not the  
extension name, unless of course they happened to be named the same  
thing. So if your controller is Admin::FooController, your view path  
should be app/views/admin/foo.

Third, in most cases, you should be passing objects as instance  
variables to views, not locals, although there should be nothing to stop  
you from explicitly rendering the view with locals.

Sean

---

<div class="post-metadata">

**Author:** ![Jan\_Rietema](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ea924/32.png) [@Jan\_Rietema](https://www.ruby-forum.com/u/Jan_Rietema)\
**Post date:** [January 3, 2008, 5:09pm UTC](https://www.ruby-forum.com/t/writing-extensions-custom-non-scaffold-views/124888/3 "2008-01-03T17:09:56Z")

</div>

Sean,

Thanks for the quick response, I was somehow expecting views to be  
“nested” inside Radiant (for a reason I fail to recall now), but on  
second sight app/views/admin/ is actually a straight-forward  
and logical path for the views.

Now that the view works without a render hack, I can reference instance  
variables in the view without problems.

One thing I noticed is that there isn’t a flash[:notice] display when  
redirecting to the main admin page. But otherwise, all is well!

Jan

On Thu, 03 Jan 2008 08:33:40 -0600
