How to insert class name with link_to

For example:

www.example.com

Thanks

Bontina C. wrote:

For example:

www.example.com

Thanks

Something like:
autolink “Come to htttp://www.example.com”, href_options = {:class =>
“example_class”}

or

autolink “Come to htttp://www.example.com”, href_options =
{class=“example_class”}

Haven’t really tried.

link_to(name, options = {}, html_options = nil,
*parameters_for_method_reference)

so that would be

link_to “mylink”, { :controller => “mycontroller”, :action =>
“myaction” }, { :class => “myclass” }

becomes

mylink

Chris H. wrote:

link_to(name, options = {}, html_options = nil,
*parameters_for_method_reference)

so that would be

link_to “mylink”, { :controller => “mycontroller”, :action =>
“myaction” }, { :class => “myclass” }

becomes

mylink

But you still need to use auto_link (auto_link_urls), when it’s an
external link, right?

i don’t see how auto_link has anything to do with his question. he
asked about adding a class attribute using link_to

and to answer your question, no. autolink just replaces urls and/or
email addresses in a string with the appropriate anchor tag. doesn’t
matter where the url goes.

Chris H. wrote:

i don’t see how auto_link has anything to do with his question. he
asked about adding a class attribute using link_to

and to answer your question, no. autolink just replaces urls and/or
email addresses in a string with the appropriate anchor tag. doesn’t
matter where the url goes.

Can you use link_to when you want to link to an external site at all?
http://www.imdb.com/bestmovieever/img/2.jpg ? That’s why I used
auto_link, filters through and makes a link of http://whatever.

auto_link “go here: http://www.yahoo.com and send an email to
[email protected]

translates to

"go here: http://www/yahoo.com and
send an email to <a href=“mailto:[email protected]>[email protected]

link_to “go here” “http://www.yahoo.com

translates to

go here

there’s a difference. one replaces urls and email addresses with
anchor tags in a string, the other generates an anchor tag from a name
and url (and any options).