Reputation: 2386
I have class that generate some js. Where i should put this class and how call methods from it in views?
class Hits
@@config = Settings.statistic
class << self
def js_counter
if @@config.enable
...
end
end
end
end
Thank you!
Upvotes: 0
Views: 94
Reputation: 4496
Put class to models directory if you want.
In a view:
<%= javascript_tag Hits.js_counter.html_escape $>
# if js_counter returns String
Upvotes: 0