Looking to embed the html 'right guillemet' (») inside of a link_to reference in my view code...

<%= (role.rights.sort{|a, b| [a.controller, a.action] <=> [b.controller, b.action]}.collect{|rights| [link_to (rights.controller + " &raquo; " + rights.action, :controller => "rights", :action => "edit", :id => rights.id)]}).join("<br />").html_safe -%>

which results in...

<a href="/rights/edit/53">groups &amp;raquo; add_member</a><br /><a href="/rights/edit/50">groups &amp;raquo; create</a><br /><a href="/rights/edit/54">groups &amp;raquo; delete_member</a><br /><a href="/rights/edit/52">groups &amp;raquo; destroy</a>

which is not what I want obviously.

(and yes, I will probably just move this to a helper once I get it working)

Is it possible to embed HTML code inside the 'link_to' ?

--
Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ craig.white@ttiltd.com
1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ www.ttiassessments.com

Need help communicating between generations at work to achieve your desired success? Let us help!

--
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@googlegroups.com.
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.

Search Discussions

  • Charles A. Lopez at Jan 16, 2012 at 5:21 pm
    Give an example of the html code.


    On 16 January 2012 12:15, Craig White wrote:

    Looking to embed the html 'right guillemet' (&raquo;) inside of a link_to
    reference in my view code...

    <%= (role.rights.sort{|a, b| [a.controller, a.action] <=> [b.controller,
    b.action]}.collect{|rights| [link_to (rights.controller + " &raquo; " +
    rights.action, :controller => "rights", :action => "edit", :id =>
    rights.id)]}).join("<br />").html_safe -%>

    which results in...

    <a href="/rights/edit/53">groups &amp;raquo; add_member</a><br /><a
    href="/rights/edit/50">groups &amp;raquo; create</a><br /><a
    href="/rights/edit/54">groups &amp;raquo; delete_member</a><br /><a
    href="/rights/edit/52">groups &amp;raquo; destroy</a>

    which is not what I want obviously.

    (and yes, I will probably just move this to a helper once I get it working)

    Is it possible to embed HTML code inside the 'link_to' ?

    --
    Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    craig.white@ttiltd.com
    1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    www.ttiassessments.com

    Need help communicating between generations at work to achieve your
    desired success? Let us help!

    --
    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@googlegroups.com.
    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@googlegroups.com.
    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.
  • Craig White at Jan 16, 2012 at 5:25 pm
    I just did (&raquo; is the html I want embedded inside the 'link_to')

    Craig
    On Jan 16, 2012, at 10:21 AM, Charles A. Lopez wrote:

    Give an example of the html code.



    On 16 January 2012 12:15, Craig White wrote:
    Looking to embed the html 'right guillemet' (&raquo;) inside of a link_to reference in my view code...

    <%= (role.rights.sort{|a, b| [a.controller, a.action] <=> [b.controller, b.action]}.collect{|rights| [link_to (rights.controller + " &raquo; " + rights.action, :controller => "rights", :action => "edit", :id => rights.id)]}).join("<br />").html_safe -%>

    which results in...

    <a href="/rights/edit/53">groups &amp;raquo; add_member</a><br /><a href="/rights/edit/50">groups &amp;raquo; create</a><br /><a href="/rights/edit/54">groups &amp;raquo; delete_member</a><br /><a href="/rights/edit/52">groups &amp;raquo; destroy</a>

    which is not what I want obviously.

    (and yes, I will probably just move this to a helper once I get it working)

    Is it possible to embed HTML code inside the 'link_to' ?

    --
    Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ craig.white@ttiltd.com
    1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ www.ttiassessments.com

    Need help communicating between generations at work to achieve your desired success? Let us help!

    --
    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@googlegroups.com.
    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@googlegroups.com.
    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.
    --
    Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ craig.white@ttiltd.com
    1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ www.ttiassessments.com

    Need help communicating between generations at work to achieve your desired success? Let us help!

    --
    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@googlegroups.com.
    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.
  • Colin Law at Jan 16, 2012 at 5:27 pm

    On 16 January 2012 17:15, Craig White wrote:
    Looking to embed the html 'right guillemet' (&raquo;) inside of a link_to reference in my view code...

    <%= (role.rights.sort{|a, b| [a.controller, a.action] <=> [b.controller, b.action]}.collect{|rights| [link_to (rights.controller + " &raquo; " + rights.action, :controller => "rights", :action => "edit", :id => rights.id)]}).join("<br />").html_safe -%>

    which results in...

    <a href="/rights/edit/53">groups &amp;raquo; add_member</a><br /><a href="/rights/edit/50">groups &amp;raquo; create</a><br /><a href="/rights/edit/54">groups &amp;raquo; delete_member</a><br /><a href="/rights/edit/52">groups &amp;raquo; destroy</a>

    which is not what I want obviously.

    (and yes, I will probably just move this to a helper once I get it working)

    Is it possible to embed HTML code inside the 'link_to' ?
    One way is to use "#{rights.controller} &raquo; #{rights.action}".html_safe

    Colin
    --
    Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ craig.white@ttiltd.com
    1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ www.ttiassessments.com

    Need help communicating between generations at work to achieve your desired success? Let us help!

    --
    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@googlegroups.com.
    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.


    --
    gplus.to/clanlaw

    --
    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@googlegroups.com.
    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.
  • Craig White at Jan 16, 2012 at 6:11 pm

    On Jan 16, 2012, at 10:26 AM, Colin Law wrote:
    On 16 January 2012 17:15, Craig White wrote:
    Looking to embed the html 'right guillemet' (&raquo;) inside of a link_to reference in my view code...

    <%= (role.rights.sort{|a, b| [a.controller, a.action] <=> [b.controller, b.action]}.collect{|rights| [link_to (rights.controller + " &raquo; " + rights.action, :controller => "rights", :action => "edit", :id => rights.id)]}).join("<br />").html_safe -%>

    which results in...

    <a href="/rights/edit/53">groups &amp;raquo; add_member</a><br /><a href="/rights/edit/50">groups &amp;raquo; create</a><br /><a href="/rights/edit/54">groups &amp;raquo; delete_member</a><br /><a href="/rights/edit/52">groups &amp;raquo; destroy</a>

    which is not what I want obviously.

    (and yes, I will probably just move this to a helper once I get it working)

    Is it possible to embed HTML code inside the 'link_to' ?
    One way is to use "#{rights.controller} &raquo; #{rights.action}".html_safe
    ----
    I understand the process of using the #{} but that is still in the middle of 'link_to' rails_tag helper and it seems that is the problem I am having.

    Craig

    --
    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@googlegroups.com.
    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.
  • Tim Shaffer at Jan 16, 2012 at 6:21 pm
    The problem is that the "inner" string is not marked as html_safe. In your
    link_to tag, this string is not considered html_safe:

    link_to(*rights.controller + " &raquo; " + rights.action*, :controller
    => "rights", :action => "edit", :id => rights.id)

    Colin's suggestion, which is the solution, is to mark the inner string as
    html_safe. The easiest way to do this is to use the #{} notation instead of
    string concatenation:

    link_to(*"#{rights.controller} &raquo; #{rights.action}".html_safe*,
    :controller => "rights", :action => "edit", :id => rights.id)

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/_P4uFObG3f0J.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    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.
  • Craig White at Jan 16, 2012 at 6:43 pm

    On Jan 16, 2012, at 11:21 AM, Tim Shaffer wrote:

    The problem is that the "inner" string is not marked as html_safe. In your link_to tag, this string is not considered html_safe:

    link_to(rights.controller + " &raquo; " + rights.action, :controller => "rights", :action => "edit", :id => rights.id)

    Colin's suggestion, which is the solution, is to mark the inner string as html_safe. The easiest way to do this is to use the #{} notation instead of string concatenation:

    link_to("#{rights.controller} &raquo; #{rights.action}".html_safe, :controller => "rights", :action => "edit", :id => rights.id)
    ----
    I see said the blind man

    and thanks Colin for the solution which was not apparent to me and I did have to clean up the syntax errors but it works.

    Thanks

    Craig

    --
    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@googlegroups.com.
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 16, '12 at 5:15p
activeJan 16, '12 at 6:43p
posts7
users4
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase