M
M
Max2015-10-16 22:08:15
Ruby on Rails
Max, 2015-10-16 22:08:15

How to check condition in Slim (Rails)?

Hello, I want to check if the user is registered and display a button for him, and vice versa. In short, you need to check the condition, but I haven’t figured out the template engine yet, I’m just experimenting. Help me please.

- if user_signed_in?
.title
= link_to 'Новый пост', new_post_path, class: 'btn btn-success'
- else
.title_else
p "Войдите или "
= link_to 'Зарегистрируйтесь', new_user_registration_path
p " для того что бы написать новый пост"

User_signed_in feature? taken from Devise gem

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Vakulchik, 2015-10-16
@maxprof

Check the indentation inside the if and else block

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question