Ruby On Rails different views for same action (Based on User's role) -


i have ruby on rails controller display different form logged out user logged in user.

what best way approach this? (is below way ok?)

   class userscontroller < applicationcontroller       def index         if logged_in && is_admin           render 'admin_index'         end         #use default index       end     end 

sure thats fine except might 'cannot render action twice' type error (if im admin , logged in still try render default after rendering admin action)

 class userscontroller < applicationcontroller       def index         if logged_in && is_admin           render 'admin_index'         else           render          end        end     end 

might better


Comments

Popular posts from this blog

mod rewrite - Doing external redirect. .htaccess NS flag not working. How to achieve similar results? -

mysql - How to insert just year and month into date field? -