Ruby on Rails Monday, March 23, 2015

Hello.

I am having some trouble accessing a method "foo" I defined in a controller. 

I was under the impression that if "foo" is in the controller that renders bar.html.erb, then bar.html.erb can in fact see a method in this controller provided I put the "helper_method: foo" notation in the controller. I was able to verify that foo was in fact accessible in the bar.html.erb file.

The problem is I want to access foo in alpha.js.erb. My application.js includes alpha.js (alpha.js.erb) implicitely because alpha.js.erb is in the app/assets/javascripts and application.js has "//= require_tree .". 

But alpha.js.erb cannot see foo. I have no idea how to get my custom ruby functions to become accessible in the js files. 

Would appreciate help. I scoured google for a few hours already and could not find much on this.

Thanks.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5a2078b6-c86e-4b39-b601-d242ceef804d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment