ruby on rails - How to call a helper method in view -


i have code in helper:

  def app_state(app)     state = app.operator_apps.map(&:is_production)     if state.include?(true) , state.include?(false)       "sandbox/production"     elsif state.include?(true)       "production"     else       "sandbox"     end   end 

and in view have done this:

<%= app.app_state %> 

i following error:

actionview::template::error (undefined method `app_state' #):

please me out in solving this.

the error getting persist unless app_state method defined somewhere within app's model.

try calling helper method so:

<%= app_state(app) %> 

now app object being passed in argument of app_state method, instead of method being called on object itself.

hope helps!


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -