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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Fernando Perez 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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.