Hello,
I would like to use the helper strip_links(html) in one of my rake task.
Is there anyway I can do that ? I've tried to look for solutions on Google with no success.
Thank you very much,
Pierre
Hello,
I would like to use the helper strip_links(html) in one of my rake task.
Is there anyway I can do that ? I've tried to look for solutions on Google with no success.
Thank you very much,
Pierre
Write this code in some file in lib folder:
def helper Helper.instance end
class Helper include Singleton include ActionView::Helpers::TextHelper end
then you can access your helper method in models and controllers (that way you could use it in rake tasks too i believe) using helper.strip_links
I don't know if its work in a rake task, but since rails 2.1, there is another way to to this :
ApplicationController.helpers.strip_links
Hope it will help
@Gabriel : Thanks so much! ApplicationController.helpers.strip_links worked fine in rake.
@Andrius : thanks for your answer (I haven't tried it, since Gabriel's is more simple).
Have a nice day! Pierre
Gabriel Laskar wrote: