【发布时间】:2019-10-24 05:12:27
【问题描述】:
只是一个简单的问题,我是 Rails 上的新蜜蜂,我想知道如何在 Rails 中使用 partials,比如我们如何与 react 中的组件交互,rails 只是一个简单的例子。
以下是我尝试过的代码。我想渲染自定义导航栏
<% @nav_links = ['hello','welcome','sign up']
@showDropdown = false
@isAuth = false
%>
<%= render 'shared/navlinks' , locals: {nav_links: @nav_links, showDropdown: @showDropdown , isAuth: @isAuth } %>```
I tried the above code to pass the variables into a partial but is there a way like the below
```rubyonrails
<%= render 'shared/navlinks' ,
locals: {nav_links: ['hello','welcome','sign up'],
showDropdown: false ,
isAuth: false } %>```
I am getting `undefined local variable or method` I feel like I am missing something here is this how the instance variable works in ruby
? Any suggestion is much appreciated... Thank you
【问题讨论】: