2015-07-28 52 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" } 
相關問題