简体   繁体   中英

Ruby: How do you pass in multiple :locals into index.erb?

    somevariable = "hello"
    answer = {yesorno: "yes"}
    anotheranswer = {whatisit: somevariable}
    erb :index, :locals => answer, anotheranswer

When I try to run the server it says :

syntax error, unexpected '\\n', expecting =>.

If I remove the anotheranswer from the locals, then it just passes in that one answer, and it works fine.

How do I pass in multiple :locals ?

它们都必须在同一哈希中。

erb :index, :locals => { whatisit: somevariable, yesorno: "yes" }

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM