Strip_links(html) in a rake task

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

On Aug 6, 11:37 am, Pierre P. [email protected]

@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 L. wrote:

On Wed, Aug 6, 2008 at 12:10 PM, Andrius C.
[email protected] wrote:

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 L. [email protected]

On Wed, Aug 6, 2008 at 12:10 PM, Andrius C.
[email protected] wrote:

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 L. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs