簡體   English   中英

Ruby:如何將多個:locals傳遞給index.erb?

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

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

當我嘗試運行服務器時,它說:

語法錯誤,意外的'\\ n',期望=>。

如果我刪除anotheranswer從當地人,那么它只是在傳遞一個答案,並能正常工作。

如何傳遞多個:locals

它們都必須在同一哈希中。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM