Helper methods in coffescript files

16 views
Skip to first unread message

Jonathan Borg

unread,
Jun 20, 2011, 4:31:08 AM6/20/11
to Ruby on Rails: Talk
Hi, I was wondering if there is a way to make helper methods available
in my .coffe files, Im trying to generate a graph from some userdata
with a javascript library, and with the new asset pipeline I can
append .erb so its users.js.coffe.erb which works just great, but I
need some way to get the current_user helper method.. help ?

Walter Lee Davis

unread,
Jun 20, 2011, 10:30:18 AM6/20/11
to rubyonra...@googlegroups.com

I am not sure this is such a good idea. Your js, ideally, will be
concatenated and compressed and cached. Anything variable ought to be
in the HTML, since that changes more frequently, and your js should
simply look for the variable within the page and act upon it in the DOM.

Walter

robertj

unread,
Aug 4, 2011, 7:59:01 AM8/4/11
to rubyonra...@googlegroups.com
Hi,

apart from the fact, that it might not be a good idea in terms of performance ...
Is it possible? I am trying the same.

Best regards

Robert

Noel

unread,
Aug 4, 2011, 8:32:49 AM8/4/11
to rubyonra...@googlegroups.com
you can do
myfile.js.coffee.erb

first it will be processed by ERB then CoffeeScript

> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/oTzNpWJ1mgsJ.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-ta...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>

Noel

unread,
Aug 4, 2011, 8:33:59 AM8/4/11
to rubyonra...@googlegroups.com
sorry, had not read the full original post

robertj

unread,
Aug 4, 2011, 8:36:00 AM8/4/11
to rubyonra...@googlegroups.com
Hi Noel,

thanks - the question is concerning helper methods. How can I use helper methods in the asset pipeline?

Best regards
Reply all
Reply to author
Forward
0 new messages