Coloring HTML elements depending on what action is called

Hi fellows. I’m requiring a suggestion, a hand, since can’t solve this.
What I’m trying to do is this:

I have 2 actions by a controller. There’s an active layout for
both(application.html.erb). There’s two HTML elements defined in the
layout which I want to be collored diferently if one action is called or
the another. I suspect that can be done with Javascript, but must be an
easy way. What I though is that when I call one of the actions, it must
render a specific CSS file, which overwrite the style of the HTML
elements(defined by default in application.css), giving to them the
color I want, but…I can’t give with it, can’t get it work correctly.
Can you give me a clue about what should I do, I’ve been around this a
whole day.

On Sun, Jun 15, 2014 at 6:40 PM, Damián M. González
[email protected] wrote:

I have 2 actions by a controller. There’s an active layout for
both(application.html.erb). There’s two HTML elements defined in the
layout which I want to be collored diferently if one action is called or
the another.

Why not just define CSS classes for the two styles in a common
style sheet and set an instance variable in the controller to pass to
the view? e.g.

...

I can imagine other approaches, but that seems simplest.

FWIW,

Hassan S. ------------------------ [email protected]
http://about.me/hassanschroeder
twitter: @hassan

Yes Hassan that’s a big better solution than the JS one, you opened my
mind, I appreciate it, thanks. Still I’m open to receive other
suggestions of ways to do this, for the sake of learn.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs