Forum: Ruby on Rails change color of links

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Maulin p. (Guest)
on 2009-01-13 05:55
I have the following code in one of my views

<div id="right"
<%= link_to_remote( "#{l.name}", :update => "right", :url =>{ :action =>
:show_stats, :ladder_id => l.id }) %><br>
</div>

I want to change the default color of the link from blue to white. I
have tried using html_options like so

 <%= link_to_remote( "#{l.name}", :update => "right", :url =>{ :action
=> :show_stats, :ladder_id => l.id }, :html_options => {:color =>
"white"}) %><br>

I have also tried wrapping the link_to in separate div tags and changing
the color there, but none of this has worked. The links are still the
default blue.

I am running rails 2.2.2
Andrew T. (Guest)
on 2009-01-13 06:20
(Received via mailing list)
On Tue, Jan 13, 2009 at 5:55 AM, Maulin pa
<removed_email_address@domain.invalid
> wrote:

>
> Posted via http://www.ruby-forum.com/.
>
> >
>
Try: <%= link_to_remote( "#{l.name}", :update => "right", :url =>{
:action
=> :show_stats, :ladder_id => l.id }, :html_options => {:style =>
"color:white"}) %>
This applies a style attribute to the link and the CSS then handles the
color
You can't wrap the call in divs because they won't override a link's
color,
that can only be done directly to the link.

--
Andrew T.
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

"I have never let my schooling interfere with my education" - Mark Twain
Matthew C. (Guest)
on 2009-01-13 11:29
(Received via mailing list)
It looks like you have a broken div. Try this:

<div id="right">
    <%= link_to_remote( "#{l.name}", :update => "right", :url =>
{ :action => :show_stats, :ladder_id => l.id }) %>
</div>

Then style it in the css with:

div#right a {color: #fff}

Matt



On Jan 12, 10:55 pm, Maulin pa <removed_email_address@domain.invalid>
Maulin p. (Guest)
on 2009-01-14 03:47
@Matthew,
The div tag is not broken, that was a typo on my part, sorry about that.
Styling the div in the css does not work.

@Andrew
I tried your syntax and that does not seem to change the link color
either. I tried putting the link_to_remote both inside and outside div
tags...no go.

Anybody else have any suggestions?
Andrew T. (Guest)
on 2009-01-14 05:34
(Received via mailing list)
On Wed, Jan 14, 2009 at 3:47 AM, Maulin pa
<removed_email_address@domain.invalid
> wrote:

> Anybody else have any suggestions?
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
Sorry, another tired answer, try:
<%= link_to_remote( "#{l.name}", {:update => "right", :url =>{ :action
=>
:show_stats, :ladder_id => l.id }}, {:style => "color:white"} ) %>

The method signagure for link_to_remote is:
link_to_remote(name, options = {}, html_options = nil)

so you need to include the display text, a hash of options for the
remote
link and then a second hash for the html specific options so it's best
to
use explicit hashes so you know which is which
link_to_remote( name, {}, {} )

--
Andrew T.
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

"I have never let my schooling interfere with my education" - Mark Twain
Maulin p. (Guest)
on 2009-01-15 02:25
> so you need to include the display text, a hash of options for the
> remote
> link and then a second hash for the html specific options so it's best
> to
> use explicit hashes so you know which is which
> link_to_remote( name, {}, {} )

Andrew, that worked perfectly. Woohoo! Thanks :)
This topic is locked and can not be replied to.