css - Make the value of the course type a unique color using rails -
i have different courses , want add unique color different types of courses. ex video course, reading course , speaking course.
i understand code does. ask if type_of_course "video" in present, , is, how display "orange" color courses have "video" course type?
<% @courses.each |course| %> <td class='<%= "type_of_course" if course.type_of_course? %>'> <%= course.title %> <% end %>
courses.scss
.type_of_course { color: orange; }
course.rb
def type_of_course? type_of_course = course.find_by(type_of_course: 'video').present? end
sorry bad explanation. figured out after few hours! anyway! :)
.level-easy .level { background-color:green; text-transform: uppercase; width: } .level-medium .level { background-color:orange; } .level-hard .level { background-color:red; }
<tr class='level-<%= course.level %>'> <td class="text-center level"><%= course.level.upcase %></td>
Comments
Post a Comment