2015-07-28 21 views
0
somevariable = "hello" 
    answer = {yesorno: "yes"} 
    anotheranswer = {whatisit: somevariable} 
    erb :index, :locals => answer, anotheranswer 

当我尝试运行它说服务器:Ruby:你如何将多个locals传入index.erb?

语法错误,意想不到的 '\ n',期待=>。

如果我从当地人中删除anotheranswer,那么它只是通过一个答案,并且它工作正常。

如何传递多个:locals

回答

1

他们都必须在同一个散列。

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