This code outputs html to the page not the icons, ideas?
def pub_social_links(pub)
html = “”
twit = pub.twitter.blank? ? [‘off’,"#{pub.twitter}",‘disabled’] :
[‘on’,’’,’’]
rss = pub.rss.blank? ? [‘off’,"#{pub.rss}",‘disabled’] : [‘on’,’’]
fb = pub.facebook.blank? ? [‘off’,"#{pub.facebook}",‘disabled’] :
[‘on’,’’,’’]
html << link_to( “image_tag(‘icons/rss_#{rss[0]}.png’)”, rss[1],
:disabled => “#{rss[2]}”)
html << link_to( “image_tag(‘icons/twitter_#{twit[0]}.png’)”,
“#{twit[1]}”, :disabled => “#{twit[2]}”)
html << link_to( “image_tag(‘icons/facebook_#{fb[0]}.png’)”,
“#{fb[1]}”, :disabled => “#{fb[2]}”)
return html
end
image_tag(‘icons/rss_off.png’)image_tag(‘icons/twitter_off.png’)image_tag(‘icons/facebook_off.png’)
Because you are returnning the helpers as strings, values… not
function
calls. remove the encapsulating double quotes so that
* html << link_to( "image_tag('icons/rss_#{rss[0]}.png')", rss[1],
:disabled => “#{rss[2]}”)*
will be
* html << link_to(image_tag(‘icons/rss_#{rss[0]}.png’), rss[1],
:disabled => “#{rss[2]}”)*
On Mon, Dec 20, 2010 at 6:44 AM, Me [email protected] wrote:
[‘on’,‘’,‘’]
disabled=“disabled”>image_tag(‘icons/twitter_off.png’)<a href=“”
http://groups.google.com/group/rubyonrails-talk?hl=en.
–
Mahmoud Said
Software Engineer - eSpace
Chris H. wrote in post #969486:
This code outputs html to the page not the icons, ideas?
Rails 3 escapes HTML by default, remember?
[…]
html << link_to( "image_tag('icons/rss_#{rss[0]}.png')", rss[1],
:disabled => “#{rss[2]}”)
You dont need #{} if there’s nothing else in the string – just use
:disabled => rss[2] .
Best,
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
Sent from my iPhone