• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

Rails2.1以降

2.1以降はview以外からhelpersにアクセスできるようになるようです。via 瀧内さん

   1  ApplicationController.helpers.simple_format(text)
http://www.nomedojogo.com/livro/carlosbrando-rubyonrails21_en.pdfより

Rails2.1以前

私の現状の環境では2.1でないので、ぐぐってみたらいい感じのがありました。
http://snippets.dzone.com/posts/show/1799

ApplicationControllerに挿入すればok

   1    def help
   2      Helper.instance
   3    end
   4  
   5    class Helper
   6      include Singleton
   7      include ActionView::Helpers::TextHelper
   8  
   9      def h(string)  
  10        ERB::Util.html_escape(string)
  11      end
  12    end
(注)オリジナルのsnippetにdef hを追加しています。

posted by Png satoko on Fri 25 Jul 2008 at 05:51 with 2 comments

Comments:

Face ogijun over 15 years ago.

2.0以前では、セカちゃんの手法が力業で興味深かったでsう。 http://subtech.g.hatena.ne.jp/secondlife/20080610/1213098477

Png satoko over 15 years ago.

こめありがとうございますー。力業だ!新たにincludeしなくてもよいっていうのがいいですね。ありがとうございまっす!

or Preview
Social Bookmarks
  • Delicious
  • B_entry682
  • Clip_16_12_w
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ