html - How can <p> display a variable -


is there way can load variable in 'p' tag?

in test.html.erb:

<p>"#{@variable}"</p> 

and in test_controller.rb

@variable = "testing" 

however, in html, displays "#{@variable}".

how should fix it?

you need print code , interpolate it, try with:

<p><%= "#{@variable}" %></p> 

or <p><%= @variable %></p>, depending on want do, can interpolate variables.

with <p>"#{@variable}"</p> you're printing plain html, nothing being interpreted ruby.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -