user3216968
user3216968

Reputation: 85

ruby output colour options

Hi all is there a way to select a color for the ruby output below? I know we can do this via CSS/Html but wondered if there was a suffix to just add to the one line?

<%= @post.title %>

maybe I can ammend the controller to output in a certain colour.

def show

 @post = Post.find(params[:id]) (maybe add something here to change colour of output)


end

Upvotes: 1

Views: 47

Answers (1)

xlembouras
xlembouras

Reputation: 8295

No there isn't.

The only relevant thing that comes to mind is to add some control variables which will produce some inline styling. But that is too ugly for me to post :-p

Rails is an MVC that helps by simplifying some things on programming part and in structuring the code in a certain way by providing some best practices (which of course can be overridden if there is a good reason). One of these rules is that the controller part should not participate in the final html presentation, that is the views responsibility.

The best approach IMO is to have something like that in your view:

<p class="<%= class_helper %">>
  <%= @post.title %>
</p>

and implement a class_helper that decides what class should be applied. (and of course the relevant css rules)

Upvotes: 2

Related Questions