This is getting perhaps a little too complex for my mind to handle. What I''m trying to accomplish is to generate a list of of hosts which are clickable links from my related Person model. Person # return an array with links def hostlist_linked if self.host == nil then results = [] else results = self.host.sort {|a,b| a <=> b }.collect { |host| "link_to " + Setting[:base_url] + "/hosts/" + host + ", " + host + "<br>" } end return results end and my view code has this... <%= (@person.hostlist_linked.each do |host| host; end).to_s.html_safe %> but that doesn''t actually give me links and just outputs the URL as text and the link_to doesn''t actually function. Is this possible? -- Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ craig.white-wmL3h9Ogt9DQT0dZR+AlfA@public.gmane.org 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-/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.
On 6 December 2011 19:32, Craig White <craig.white-wmL3h9Ogt9DQT0dZR+AlfA@public.gmane.org> wrote:> This is getting perhaps a little too complex for my mind to handle. > > What I''m trying to accomplish is to generate a list of of hosts which are clickable links from my related Person model. > > Person # return an array with links > def hostlist_linked > if self.host == nil then > results = [] > else > results = self.host.sort {|a,b| a <=> b }.collect { |host| "link_to " + Setting[:base_url] + "/hosts/" + host + ", " + host + "<br>" } > > end > return results > end > > and my view code has this... > <%= (@person.hostlist_linked.each do |host| host; end).to_s.html_safe %> > > but that doesn''t actually give me links and just outputs the URL as text and the link_to doesn''t actually function.The link_to must be executed as ruby, which your code makes no attempt to do. Much easier just to put the urls in the collection then do the link_to in the loop, something like <% @person.hostlist_linked.each do |host| %> <%= link_to host %> <% end %> Colin -- 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.
On Dec 6, 2011, at 1:39 PM, Colin Law wrote:> On 6 December 2011 19:32, Craig White <craig.white-wmL3h9Ogt9DQT0dZR+AlfA@public.gmane.org> wrote: >> This is getting perhaps a little too complex for my mind to handle. >> >> What I''m trying to accomplish is to generate a list of of hosts which are clickable links from my related Person model. >> >> Person # return an array with links >> def hostlist_linked >> if self.host == nil then >> results = [] >> else >> results = self.host.sort {|a,b| a <=> b }.collect { |host| "link_to " + Setting[:base_url] + "/hosts/" + host + ", " + host + "<br>" } >> >> end >> return results >> end >> >> and my view code has this... >> <%= (@person.hostlist_linked.each do |host| host; end).to_s.html_safe %> >> >> but that doesn''t actually give me links and just outputs the URL as text and the link_to doesn''t actually function. > > The link_to must be executed as ruby, which your code makes no attempt > to do. Much easier just to put the urls in the collection then do the > link_to in the loop, something like > <% @person.hostlist_linked.each do |host| %> > <%= link_to host %> > <% end %>---- which is what I ended up doing. I thought I posted a follow up but sometimes this stupid Apple Mail sends it to myself instead (when I reply to the list). 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-/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.