Answer the question
In order to leave comments, you need to log in
How to display in the Rails view the field in which the Ruby code is located?
There is a Block model that is displayed in custom regions in templates. The idea was that the client could add these blocks through the admin panel and could insert both html and Ruby code into the body field (PARTICULARLY A SMALL FORM). And then in the views this block is displayed with the contents of the body field.
So when I insert this output in the view like this: <%= @block.body.html_safe %> It outputs html normally, but the Ruby code does not process it and outputs it as text.
How to correctly write the output of this field so that both html and Ruby code are processed?
Thanks!!!
Answer the question
In order to leave comments, you need to log in
ERB.new('<%= "Hello World" %>').result
But in general the idea is a bit dubious.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question