Rails 4 - passing variable to partial

后端 未结 7 1447
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 03:49

I am following the Ruby on Rails tutorial and have come across a problem while trying to pass variables to partials.

My _user partial is as follows

7条回答
  •  星月不相逢
    2020-11-28 04:09

    Syntactically a little different but it looks cleaner in my opinion:

    render 'my_partial', locals: { title: "My awesome title" }
    
    # not a big fan of the arrow key syntax
    render 'my_partial', :locals => { :title => "My awesome title" }
    

提交回复
热议问题