Hi all, Can anyone tell me what it is I''ve done wrong with the following? I''m wanting to use images to link to the page in the site. So I have this: <%= link_to(image_tag "about.png", :border =>"0", :controller => "site", :action => "about") %> Unfortunately, the image doesn''t link as I''d expected. The page renders, but that''s all. Can anyone help? I know it''s probably something REALLY obvious, but i just can pin it down Many Thanks. -- 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.
oops... Spotted the issue: the correct line should be: <%= link_to image_tag ("about.png", :border =>"0"), :controller => "site", :action => "about" %> That works now. On Nov 23, 6:19 pm, RubyonRails_newbie <craigwest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > Can anyone tell me what it is I''ve done wrong with the following? > > I''m wanting to use images to link to the page in the site. > > So I have this: > > <%= link_to(image_tag "about.png", :border =>"0", :controller => > "site", :action => "about") %> > > Unfortunately, the image doesn''t link as I''d expected. The page > renders, but that''s all. > > Can anyone help? I know it''s probably something REALLY obvious, but i > just can pin it down > > Many Thanks.-- 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 Nov 23, 2010, at 1:19 PM, RubyonRails_newbie wrote:> Hi all, > > Can anyone tell me what it is I''ve done wrong with the following? > > I''m wanting to use images to link to the page in the site. > > So I have this: > > <%= link_to(image_tag "about.png", :border =>"0", :controller => > "site", :action => "about") %> > > Unfortunately, the image doesn''t link as I''d expected. The page > renders, but that''s all. > > Can anyone help? I know it''s probably something REALLY obvious, but i > just can pin it down > > Many Thanks.Try placing parentheses around the arguments to each function. Think about where Ruby is presuming the argument lists are from the punctuation that you''ve given. -Rob Rob Biedenharn Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org http://AgileConsultingLLC.com/ rab-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org http://GaslightSoftware.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.
On Nov 23, 2010, at 1:29 PM, RubyonRails_newbie wrote:> oops... > > Spotted the issue: > > the correct line should be: > > <%= link_to image_tag ("about.png", :border =>"0"), :controller => > "site", :action => "about" %> > > That works now.Well, I''d suggest formatting like: <%= link_to(image_tag("about.png", :border =>"0"), :controller => "site", :action => "about") %> I might leave the parentheses off the call to link_to, but only if it didn''t break across lines in the actual source. In fact, since you''re using the hash argument form for the url construction, you really could have this and be exactly the same (from a Rails-semantics perspective): <%= link_to(image_tag("about.png", :border =>"0"), {:controller => "site", :action => "about"}, {}) %> I mention this because going back and adding an option that you expect to be given to link_to can easily be given to the underlying call to url_for that happens inside the link_to helper. You might want to take a look at an old article by James Edward Gray II http://blog.grayproductions.net/articles/do_i_need_these_parentheses Enjoy your Ruby! (and Rails) -Rob> On Nov 23, 6:19 pm, RubyonRails_newbie <craigwest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Hi all, >> >> Can anyone tell me what it is I''ve done wrong with the following? >> >> I''m wanting to use images to link to the page in the site. >> >> So I have this: >> >> <%= link_to(image_tag "about.png", :border =>"0", :controller => >> "site", :action => "about") %> >> >> Unfortunately, the image doesn''t link as I''d expected. The page >> renders, but that''s all. >> >> Can anyone help? I know it''s probably something REALLY obvious, but i >> just can pin it down >> >> Many Thanks. > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en > . >Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org +1 513-295-4739 Skype: rob.biedenharn -- 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.
Great - thanks for the feedback.... :-) On Nov 23, 7:05 pm, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> wrote:> On Nov 23, 2010, at 1:29 PM, RubyonRails_newbie wrote: > > > oops... > > > Spotted the issue: > > > the correct line should be: > > > <%= link_to image_tag ("about.png", :border =>"0"), :controller => > > "site", :action => "about" %> > > > That works now. > > Well, I''d suggest formatting like: > > <%= link_to(image_tag("about.png", :border =>"0"), > :controller => "site", :action => "about") %> > > I might leave the parentheses off the call to link_to, but only if it > didn''t break across lines in the actual source. In fact, since you''re > using the hash argument form for the url construction, you really > could have this and be exactly the same (from a Rails-semantics > perspective): > > <%= link_to(image_tag("about.png", :border =>"0"), > {:controller => "site", :action => "about"}, {}) %> > > I mention this because going back and adding an option that you expect > to be given to link_to can easily be given to the underlying call to > url_for that happens inside the link_to helper. > > You might want to take a look at an old article by James Edward Gray II > > http://blog.grayproductions.net/articles/do_i_need_these_parentheses > > Enjoy your Ruby! (and Rails) > > -Rob > > > > > > > On Nov 23, 6:19 pm, RubyonRails_newbie <craigwest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hi all, > > >> Can anyone tell me what it is I''ve done wrong with the following? > > >> I''m wanting to use images to link to the page in the site. > > >> So I have this: > > >> <%= link_to(image_tag "about.png", :border =>"0", :controller => > >> "site", :action => "about") %> > > >> Unfortunately, the image doesn''t link as I''d expected. The page > >> renders, but that''s all. > > >> Can anyone help? I know it''s probably something REALLY obvious, but i > >> just can pin it down > > >> Many Thanks. > > > -- > > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > . > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en > > . > > Rob Biedenharn http://agileconsultingllc.com > R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org > +1 513-295-4739 > Skype: rob.biedenharn- Hide quoted text - > > - Show quoted text --- 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.