Reputation:
I have this code in my helper:
def app_state(app)
state = app.operator_apps.map(&:is_production)
if state.include?(true) and state.include?(false)
"Sandbox/Production"
elsif state.include?(true)
"Production"
else
"Sandbox"
end
end
and in my view I have done this:
<%= app.app_state %>
I get the following error:
ActionView::Template::Error (undefined method `app_state' for #):
Please help me out in solving this.
Upvotes: 1
Views: 863
Reputation: 4226
The error you are getting will persist unless an app_state
method is defined somewhere within app
's model.
Try calling the helper method like so:
<%= app_state(app) %>
Now the app
object is being passed in as the argument of the app_state
method, instead of the method being called on the object itself.
Hope that helps!
Upvotes: 3