开发者

Calling Helper Method from partial view

开发者 https://www.devze.com 2023-03-05 00:53 出处:网络
In my bar.html I render a partial view and in it I want to call the method foo(var1, var2) and get an array back. On my local system everything works finde but on my production system the following er

In my bar.html I render a partial view and in it I want to call the method foo(var1, var2) and get an array back. On my local system everything works finde but on my production system the following error occurs.

undefined local variable or method `foo' for #<#<Class:0x70c6410>:0x706f480>)

Can someone explain this to me?

The Class #<#:0x706f480> changes with every call so it seems that the view does not try to search the function in my helper.

EDIT:

The application has the following structure (example)

app/helpers/bar_helper
app/views/bar/bar.html.erb
app/views/bar/partials/bar_partial.html.erb

and in bar_part开发者_C百科ial.html.erb I call foo(var1, var2) in my bar_helper like this

<% data = foo(var1, var2) %>


The problem was, that the class existed a second time somewhere in the folder structure so that ruby found the first file and used that one instead of the right one.

0

精彩评论

暂无评论...
验证码 换一张
取 消