Reputation: 737
Rails 4 + HAML.
Is there any way to consolidate this into one line?
- if current_page?(controller: 'root', action: 'sign_up')
%a Sign Up
- else
%a{href: program_sign_up_path} Sign Up
The reason is that if the link has an href, it appears to still be clickable and reloads the page on click, whereas if the user is on the sign_up page, the link either shouldn't be clickable or not go anywhere. An href with an empty string didn't do the job, but getting rid of the href altogether seems to work.
Upvotes: 1
Views: 651
Reputation: 17647
%a{href: ( program_sign_up_path unless current_page?(controller: 'root', action: 'sign_up')) } Sign Up
Upvotes: 2