Reputation: 2793
I 'm pretty new to Ruby on Rails. I'm only a bit familiar with devise and the rails/ruby methods.
I have a sign in page. I have a page that checks if the user is signed in; if he is, one partial is displayed, if not, another partial is displayed;
<%= render(user_signed_in? ? '/layouts/signed_in_header' : '/layouts/signed_out_header') %>
Now, how can I have the above, with just one html.erb exception? Is there something like an Is_not method?
I don't want the signed_in_header to be displayed if the user is logged in AND the page he is on is, say, not_here_please. It should display on every other page, if the user is signed in.
Is there something like:
<%= render(user_signed_in? ? and page_is_not 'not_here_please'
'/layouts/signed_in_header' : '/layouts/signed_out_header') %>
Thanks for any help,
Chris.
Upvotes: 0
Views: 577
Reputation: 3237
As maksimov said :
<%= render((user_signed_in? && controller.action_name != 'not_here_please') ? '/layouts/signed_in_header' : '/layouts/signed_out_header') %>
Feel free to use anything different from controller.action_name
in your condition. I just figured it was the most appropriate way to represent what you asked for.
Upvotes: 1