I
I
IlyaMalyukov2020-12-06 15:29:06
Ruby on Rails
IlyaMalyukov, 2020-12-06 15:29:06

How to rewrite Haml to erb?

I just recently started learning Rails.
I'm trying to implement the ability to like and dislike posts.
Getting error " undefined local variable or method `vote_text' "
in _reply_link.erb template

- vote_text = curent_user&.voted_for?(task) ? "Отменить отклик" : "Откликнуться"
<%= link_to vote_text, reply_task_path(task), method: :put, remote: :true %>


I rewrote the second line, but I can't figure out the first one.
If I leave it as it was and change the _reply_link.erb template extension to _reply_link.haml,
I get an error saying that the required view does not exist
Missing partial tasks/_replies with {:locale=>[:en], :formats=>[: html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Mirilaczvili, 2020-12-06
@IlyaMalyukov

erb:

<% vote_text = curent_user&.voted_for?(task) ? "Отменить отклик" : "Откликнуться" %>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question