Passing local variables to a view from controller

后端 未结 5 886
鱼传尺愫
鱼传尺愫 2021-02-14 05:57

I am not able for some reason to pass local variables to the show view...

In my controller i have simply:

def show
  render template: \"books/show\", :re         


        
5条回答
  •  星月不相逢
    2021-02-14 06:47

    You can't pass local variables from a controller to a view. What you could do is define it as an instance variable and then it would automatically be available in the view.

    @resource = @book
    

    If you want to pass entirely different objects, then just define those instance variables differently.

提交回复
热议问题