Rails 3.1.3 I would like to generate something like this. <div class="alert"> <a class="close" data-dismiss="alert">×</a> Successful! </div> I tried, content_tag :div, msg, :class => "alert alert-success" do content_tag :a, "x", :class => "close", :data-dismiss => "alert" end But the problem is the hyphen, "-", where ":data-dismiss =>..." Do you think we can avoid this problem? soichi -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Have you tried "data-dismiss".to_sym? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Lee Davis
2012-Mar-17 21:00 UTC
Re: Dynamically generating selector, hyphen problem
On Mar 17, 2012, at 4:52 PM, Soichi Ishida wrote:> Rails 3.1.3 > > > I would like to generate something like this. > > <div class="alert"> > <a class="close" data-dismiss="alert">×</a> > Successful! > </div> > > I tried, > > content_tag :div, msg, :class => "alert alert-success" do > content_tag :a, "x", :class => "close", :data-dismiss => "alert" > end > > > But the problem is the hyphen, "-", where ":data-dismiss =>..." > Do you think we can avoid this problem?You can either use a bare string (''data-dismiss'' => "alert") or you can use quotes in the symbol name (:"data-dismiss" => "alert"). Walter> > soichi > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
A bare string works! Thanks, everyone! soichi -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.