I'm using Rails 5. What is the equivalent of JSP's c:set in a Rails view? In JSP you can set a page variable like so
<c:set var="myVar" value="myValue" />
How do I do that in a Rails view? Note that I'm invoking this logic from within a loop in my Rails view so each iteration could set the variable to something else. As such, I do not want any logic in my controller, only in my view.
A typical Rails app uses ERB. This can look like:
<%- myVar = myValue %>
http://guides.rubyonrails.org/action_view_overview.html#templates-partials-and-layouts
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.