Forum: Ruby on Rails content_tag can not work?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Charlie (Guest)
on 2006-04-11 18:40
the tag helper "content_tag" can not work correnctedly on my enviroment:
page.insert_html :bottom, 'body', content_tag("div","id"=>"tag")

then in body,i can only get "idtag" as the text!

but if i use : content_tag("p","hello world")
I can get it worked. From the rails 1.1 api document,i can find the
example of using content_tag in the former way,what is the matter with
that? Or i have made some mistakes?
Philip R. (Guest)
on 2006-04-11 21:07
(Received via mailing list)
Charlie wrote:
> the tag helper "content_tag" can not work correnctedly on my enviroment:
> page.insert_html :bottom, 'body', content_tag("div","id"=>"tag")
>
> then in body,i can only get "idtag" as the text!
>
> but if i use : content_tag("p","hello world")
> I can get it worked. From the rails 1.1 api document,i can find the
> example of using content_tag in the former way,what is the matter with
> that? Or i have made some mistakes?

content_tag requires that you specify some content as the second
parameter. To create an empty div with id tag, use

content_tag("div", "", "id"=>"tag")

Alternatively, you can use the tag helper method:

tag("div", "id"=>"tag")

--
Philip R.
http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby
This topic is locked and can not be replied to.