E
E
Eugene Peluhnya2015-03-11 02:03:22
Ruby on Rails
Eugene Peluhnya, 2015-03-11 02:03:22

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

2 answer(s)
V
Viktor Vsk, 2015-03-11
@Peluhnya

ERB.new('<%= "Hello World" %>').result
But in general the idea is a bit dubious.

U
UIRobot, 2015-03-19
@UIRobot

The idea is really dubious

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question