this is my view: <td align="left"> <% setupsheets_missing = true @series800.setupsheets.each do |sheet| setupsheets_missing = false %> <%link_to( image_tag(sheet.public_filename(:small), :border=>1, :style=>"margin- right: 3p"), ''show_setup_sheet'',:popup => [''sheet window'', ''height=780,width=620'']) %> <% end if setupsheets_missing %> <% image_tag("/setupsheets/ missing_small.gif", :border=>1, :style=>"margin-right: 3px")%> <% end %> </td><td></td><td></td></tr> It works, but it is damned ugly. if attachment_fu has saved multiple files, I get a list of thumb picture links if it has only saved on I get one thumb picture link if it hasn''t any I get a image_tag to a thumb bearing the word "missing" I would like to replace the abomination in the view code above with: <td align="left"><%= sheet_links_for(@series800,:small) % ></td> and a helper routine: def sheet_links_for(series800,size = :small) sheets_present = false series800.setupsheets.each do |sheet| sheets_present = true link_to( image_tag(sheet.public_filename(size), :border=>1,:style=>"margin- right: 3px"), ''show_setup_sheet'',:popup => [''sheet window'', ''height=780,width=620'']) end unless sheets_present image_tag("/setupsheets/ missing_small.gif", :border=>1,:style=>"margin-right: 3px") end end But no... the ''missing tag'' does show up, but the two links are nowhere to be found. I have been trying to spot the error for the past week... been over this with a fine tooth comb, substituting image tags for the 2 links. any ideas? also is there a clean way to test for sheets present without introducing a local variable. Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 27, 2:01 am, ee_smajors <ee.smaj...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> But no... the ''missing tag'' does show up, but the two links are > nowhere to be found. >You need to return from the helper the entirety of what you want rendered. However the return value of your function is either the missing tag image, or (if sheets_present is true) then just nil. In the original form this was handled by you using <%= in various points, but with a helper like this you''ll have to handle this yourself eg output = "" output << link_to(...) ... and then return output from your function> also is there a clean way to test for sheets present without > introducing a local variable.if series800.setupsheets.any? ... else image_tag("/setupsheets/ missing_small.gif", :border=>1,:style=>"margin-right: 3px") end Fred> > Thanks in advance.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Fred, I did not understand the helper transfer mechanism... Thank you! :) (jubilation, joy, and much happiness :) :) Steven On Sep 27, 1:22 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sep 27, 2:01 am, ee_smajors <ee.smaj...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > But no... the ''missing tag'' does show up, but the two links are > > nowhere to be found. > > You need to return from the helper the entirety of what you want > rendered. However the return value of your function is either the > missing tag image, or (if sheets_present is true) then just nil. In > the original form this was handled by you using <%= in various points, > but with a helper like this you''ll have to handle this yourself eg > output = "" > output << link_to(...) > ... > and then return output from your function > > > also is there a clean way to test for sheets present without > > introducing a local variable. > > if series800.setupsheets.any? > ... > else > image_tag("/setupsheets/ > missing_small.gif", :border=>1,:style=>"margin-right: 3px") > end > > Fred > > > > > Thanks in advance.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---