Ruby:你如何传递多个:locals到index.erb?

时间:2015-07-28 09:22:53

标签: ruby erb

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

当我尝试运行服务器时,它说:

  

语法错误,意外' \ n',期待=>。

如果我从本地人那里删除anotheranswer,那么它只传递一个答案,并且它可以正常工作。

如何传递多个:locals

1 个答案:

答案 0 :(得分:1)

他们都必须使用相同的哈希值。

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