The appropriate place to use Textile is in the controller, right? i.e. class ArticleController < AC def show # stuff @article.body = RedCloth.new(@article.body).to_html end end Or should it go in the model? Joe
There''s a textilize method in TextHelper. Kent. On Tuesday 06 December 2005 17:21, Joe Van Dyk wrote:> The appropriate place to use Textile is in the controller, right? > > i.e. > > class ArticleController < AC > def show > # stuff > @article.body = RedCloth.new(@article.body).to_html > end > end > > Or should it go in the model? > > Joe > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
True, but the textilize method doesn''t seem to support multiple paragraphs. On 12/6/05, Kent Sibilev <ksruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> There''s a textilize method in TextHelper. > > Kent. > > On Tuesday 06 December 2005 17:21, Joe Van Dyk wrote: > > The appropriate place to use Textile is in the controller, right? > > > > i.e. > > > > class ArticleController < AC > > def show > > # stuff > > @article.body = RedCloth.new(@article.body).to_html > > end > > end > > > > Or should it go in the model? > > > > Joe > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
What do you mean by ''doesn''t support''? Kent. On Tuesday 06 December 2005 17:46, Rabbit wrote:> True, but the textilize method doesn''t seem to support multiple paragraphs. > > On 12/6/05, Kent Sibilev <ksruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > There''s a textilize method in TextHelper. > > > > Kent. > > > > On Tuesday 06 December 2005 17:21, Joe Van Dyk wrote: > > > The appropriate place to use Textile is in the controller, right? > > > > > > i.e. > > > > > > class ArticleController < AC > > > def show > > > # stuff > > > @article.body = RedCloth.new(@article.body).to_html > > > end > > > end > > > > > > Or should it go in the model? > > > > > > Joe > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Goddammit, thanks. :-) I dunno if this is clever or not, but I extended the String class: class String def to_textile RedCloth.new(self).to_html end end And then whenever I need to convert a string to textile, it''s just "this is the string".to_textile. But it''s good to know about that stuff. On 12/6/05, Kent Sibilev <ksruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> There''s a textilize method in TextHelper. > > Kent. > > On Tuesday 06 December 2005 17:21, Joe Van Dyk wrote: > > The appropriate place to use Textile is in the controller, right? > > > > i.e. > > > > class ArticleController < AC > > def show > > # stuff > > @article.body = RedCloth.new(@article.body).to_html > > end > > end > > > > Or should it go in the model? > > > > Joe > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 12/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The appropriate place to use Textile is in the controller, right? > > i.e. > > class ArticleController < AC > def show > # stuff > @article.body = RedCloth.new(@article.body).to_html > end > end > > Or should it go in the model?Are there any compelling arguments about why it shouldn''t go in the model? i.e. class Article < AR def body read_attribute(:body).to_textile # See my other post end end That''s what I''m doing now, anyways.
Joe you are a freaking genius. :) - Rabbit PS: And no, I see no compelling arguments why that shouldn''t go into the model. --- On 12/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 12/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > The appropriate place to use Textile is in the controller, right? > > > > i.e. > > > > class ArticleController < AC > > def show > > # stuff > > @article.body = RedCloth.new(@article.body).to_html > > end > > end > > > > Or should it go in the model? > > Are there any compelling arguments about why it shouldn''t go in the model? > > i.e. > > class Article < AR > def body > read_attribute(:body).to_textile # See my other post > end > end > > That''s what I''m doing now, anyways. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
If you are putting it into the model, make it something like: def body_html read_attribute(:body).to_textile end That way you can access the unproccessed text for editing. On Tue, 6 Dec 2005, Rabbit wrote:> Joe you are a freaking genius. :) > > - Rabbit > > PS: And no, I see no compelling arguments why that shouldn''t go into the model. > > --- > > On 12/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> On 12/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> The appropriate place to use Textile is in the controller, right? >>> >>> i.e. >>> >>> class ArticleController < AC >>> def show >>> # stuff >>> @article.body = RedCloth.new(@article.body).to_html >>> end >>> end >>> >>> Or should it go in the model? >> >> Are there any compelling arguments about why it shouldn''t go in the model? >> >> i.e. >> >> class Article < AR >> def body >> read_attribute(:body).to_textile # See my other post >> end >> end >> >> That''s what I''m doing now, anyways.
On 12/6/05, Ken Bowley <rails-DESCn+CieYk@public.gmane.org> wrote:> If you are putting it into the model, make it something like: > > def body_html > read_attribute(:body).to_textile > end > > That way you can access the unproccessed text for editing.That''s not necessary. Dunno why though.> On Tue, 6 Dec 2005, Rabbit wrote: > > > Joe you are a freaking genius. :) > > > > - Rabbit > > > > PS: And no, I see no compelling arguments why that shouldn''t go into the model. > > > > --- > > > > On 12/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On 12/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >>> The appropriate place to use Textile is in the controller, right? > >>> > >>> i.e. > >>> > >>> class ArticleController < AC > >>> def show > >>> # stuff > >>> @article.body = RedCloth.new(@article.body).to_html > >>> end > >>> end > >>> > >>> Or should it go in the model? > >> > >> Are there any compelling arguments about why it shouldn''t go in the model? > >> > >> i.e. > >> > >> class Article < AR > >> def body > >> read_attribute(:body).to_textile # See my other post > >> end > >> end > >> > >> That''s what I''m doing now, anyways. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >