My helper works like this:
def some_help(in_string)
in_string + " and more"
end
But I want it do to a
before the output and I keep getting the < br > characters themselves literally, i.e. not a break but what I want is a < br > that is the problem.
so
def some_help(in_string)
"<br/>" + in_string + " and more"
end
doesn't work right.
What is a helper? Basically helpers in Rails are used to extract complex logic out of the view so that you can organize your code better.
Custom helpers for your application should be located in the app/helpers directory.
Use tag(:br)
instead of "<br/>"
.
content_tag(:br)
creates opening and closing br
tags and using raw
or html_safe
is just ugly (not to mention dangerous).
you can also use the "content_tag" view helper.
http://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-content_tag
def some_help
content_tag(:br) + "some help"
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With