module UtilsHelper
def convertValue(value)
return "0" if value.nil?
return (value*2).to_s
end
end
Google around, finally get it to run:
In the Controller, use helper method to include UtilsHelper to use in the template:
class HomeController < ApplicationController
helper UtilsHelper #include won't work
end
index.rhtml template:
<%= convertValue(row.value) %>
But in a class, we must use include method
class Data
include UtilsHelper #require won't work
@value = nil
def to_s
return convertValue(@value)
end
end
No comments:
Post a Comment