laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
2008-Sep-04 03:39 UTC
How to add a class to my anchor?
Hi, I have <%= link_to ''Add a New Prescription'', :controller => ''forms'', :action => ''new'', :class => "sidebar2Text" %> which is producing <a href="/easyrx/public/order/new?class=sidebar2Text">Refill a Prescription</a> How do I make the "class" its own attribute? Thanks, - Dave --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Try this: <%= link_to ''Add a New Prescription'', {:controller => ''forms'', :action=> ''new''}, :class => "sidebar2Text" %> The link_to method receives 3 parameters, with your call, you were providing just two (the hash was counting as the 2nd one), the 3th parameter is the options hash, were you should put the HTML class. On Thu, Sep 4, 2008 at 12:39 AM, laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org <laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org> wrote:> > Hi, > > I have > > <%= link_to ''Add a New Prescription'', :controller => ''forms'', :action > => ''new'', :class => "sidebar2Text" %> > > which is producing > > <a href="/easyrx/public/order/new?class=sidebar2Text">Refill a > Prescription</a> > > How do I make the "class" its own attribute? > > Thanks, - Dave-- Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) João Pessoa, PB, +55 83 8867-7208 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org wrote:> Hi, > > I have > > <%= link_to ''Add a New Prescription'', :controller => ''forms'', :action > => ''new'', :class => "sidebar2Text" %> > > which is producing > > <a href="/easyrx/public/order/new?class=sidebar2Text">Refill a > Prescription</a> > > How do I make the "class" its own attribute? > > Thanks, - DaveDave, Since the options hash can include any extra variables as query parameters, you need to make sure that link_to realizes you''ve moved from the options hash to the html_options hash... you just need to wrap the regular options in {} like this: <%= link_to ''Add a New Prescription'', {:controller => ''forms'', :action => ''new''}, :cass => ''sidebar2Text'' %> -- Posted via http://www.ruby-forum.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-/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 -~----------~----~----~----~------~----~------~--~---