Rails: Create method available in all views and all models
- by smotchkkiss
I'd like to define a method that is available in both my views and my models
Say I have a view helper:
def foo(s)
"hello #{s}"
end
A view might use the helper like this:
<div class="data"><%= foo(@user.name) %></div>
However, this <div> will be updated with a repeating ajax call. I'm using a to_json call in a…