![](/img/trans.png)
[英]How do I use a button on the nav bar to link to another .html.erb file and display it
[英]How do I use a variable to assign a css id in an html.erb file?
我在.html.erb視圖文件中有一個要基於變量指定ID的類。
我想做這樣的事情:
<ul id="#{store}">
其中store
是一個包含字符串“ store1”的變量。
我希望它產生這樣的ul: <ul id=store1>
,但是我卻得到了<ul id=#{store}>
。
我是否需要創建一個幫助程序來幫助實現此目的,或者我忽略了某些語法?
嘗試這個:
<ul id="<%= yourvariable %>">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.