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

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.

laredotornado@zipmail.com 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

Dave,

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' %>