# Different views for different user's types

**URL:** <https://www.ruby-forum.com/t/different-views-for-different-users-types/190370>\
**Category:** Rails\
**Created:** [June 18, 2010, 5:27pm UTC](https://www.ruby-forum.com/t/different-views-for-different-users-types/190370 "2010-06-18T17:27:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![spitfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@spitfire](https://www.ruby-forum.com/u/spitfire)\
**Post date:** [June 18, 2010, 5:27pm UTC](https://www.ruby-forum.com/t/different-views-for-different-users-types/190370/1 "2010-06-18T17:27:57Z")

</div>

I have to create a web app with  
2 different user’s types: advanced and basic.

What’s the best way to manage different user’s views (one for user’s  
type) ?

I am using respond\_to in this way:

```
respond_to do |format|
  case current_operator.op_type
  when 'basic'
    format.html { render :template => "devices/index_basic.html.erb"

```

}  
when ‘advanced’  
format.html # index.html.erb  
end  
end

but I don’t like that I need to specify  
render :template =\> “devices/basic\_action\_page.html.erb” in every  
respond\_to

Do you know some cleaner way to do that ?

thank you,  
Alessandro

---

<div class="post-metadata">

**Author:** ![spitfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@spitfire](https://www.ruby-forum.com/u/spitfire)\
**Post date:** [June 18, 2010, 5:57pm UTC](https://www.ruby-forum.com/t/different-views-for-different-users-types/190370/2 "2010-06-18T17:57:30Z")

</div>

Something like:

kind = current\_operator.op\_type == “basic” ? “\_basic” : nil

format.html { render :template =\> “devices/index#{kind}.html.erb”

And factor that in its own before\_filter method or alike.

---

<div class="post-metadata">

**Author:** ![spitfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@spitfire](https://www.ruby-forum.com/u/spitfire)\
**Post date:** [June 18, 2010, 9:58pm UTC](https://www.ruby-forum.com/t/different-views-for-different-users-types/190370/3 "2010-06-18T21:58:27Z")

</div>

Fernando P. wrote:

> Something like:
> 
> kind = current\_operator.op\_type == “basic” ? “\_basic” : nil
> 
> format.html { render :template =\> “devices/index#{kind}.html.erb”
> 
> And factor that in its own before\_filter method or alike.

thank you,  
this is a good trick,  
but in this way I have to specify the template in all action (index,  
show, …)  
Does exist some solution more simple ?

Alessandro
