# Custom REST action - template question

**URL:** <https://www.ruby-forum.com/t/custom-rest-action-template-question/155603>\
**Category:** Rails\
**Created:** [December 14, 2008, 2:55pm UTC](https://www.ruby-forum.com/t/custom-rest-action-template-question/155603 "2008-12-14T14:55:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pavel\_Krusek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@Pavel\_Krusek](https://www.ruby-forum.com/u/Pavel_Krusek)\
**Post date:** [December 14, 2008, 2:55pm UTC](https://www.ruby-forum.com/t/custom-rest-action-template-question/155603/1 "2008-12-14T14:55:16Z")

</div>

Hallo phorum,

i have custom rest action.

routes.rb:  
map.resources :schools, :collection =\> { :graduations =\> :get }

SchoolsController:  
def graduations  
@schools = School.graduation(true)  
end

link somewhere in navigation:  
\<%= link\_to ‘Schools with graduation’, graduations\_schools\_path %\>

All works OK for me, but Rails needs (of course) a template for  
controller action ‘graduations’:

Template is missing

Missing template schools/graduations.erb in view path blah blah blah…

But i need to use the template ‘index.html.erb’ instead of the new  
template ‘graduations.html.erb’…

How to do this in Schools controller?  
thanks,

–  
Pavel Krusek

removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Pavel\_Krusek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@Pavel\_Krusek](https://www.ruby-forum.com/u/Pavel_Krusek)\
**Post date:** [December 14, 2008, 4:18pm UTC](https://www.ruby-forum.com/t/custom-rest-action-template-question/155603/2 "2008-12-14T16:18:25Z")

</div>

Pavel Krusek wrote:

> Hallo phorum,
> 
> i have custom rest action.
> 
> routes.rb:  
> map.resources :schools, :collection =\> { :graduations =\> :get }
> 
> SchoolsController:  
> def graduations  
> @schools = School.graduation(true)  
> end
> 
> link somewhere in navigation:  
> \<%= link\_to ‘Schools with graduation’, graduations\_schools\_path %\>
> 
> All works OK for me, but Rails needs (of course) a template for  
> controller action ‘graduations’:
> 
> Template is missing
> 
> Missing template schools/graduations.erb in view path blah blah blah…
> 
> But i need to use the template ‘index.html.erb’ instead of the new  
> template ‘graduations.html.erb’…
> 
> How to do this in Schools controller?  
> thanks,
> 
> –  
> Pavel Krusek
> 
> removed\_email\_address@domain.invalid

class SchoolsController:  
layout ‘mynewlayout’

def graduations  
end  
.  
.

And it will use your custom layout called mynewlayout

Hope this helps.  
Petr 😉  
(BTW: Äus)

---

<div class="post-metadata">

**Author:** ![Pavel\_Krusek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@Pavel\_Krusek](https://www.ruby-forum.com/u/Pavel_Krusek)\
**Post date:** [December 14, 2008, 5:02pm UTC](https://www.ruby-forum.com/t/custom-rest-action-template-question/155603/3 "2008-12-14T17:02:57Z")

</div>

Hi,

i thought the template for concrete action ‘graduations’, no template  
for layout.

Solution:

def graduations  
@schools = School.graduation(true)  
render :action =\> “index”  
end

I forgot direction ‘render’ 😉

Thanks,

Pavel

Zdar 🙂

2008/12/14 Petr B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > def graduations  
> > Template is missing  
> > Pavel Krusek

–  
Pavel Krusek

+420 602 641 039  
irb(main):001:0\> ( ‘pavel.krusekATgmail.\_see\_om’.gsub(‘_see_’,  
‘c’).gsub(‘AT’, ‘@’) )
