Making the logo interchangeable. Should I do it through the scss.erb or in the applications layout?

I am trying to make the logo of my rails app interchangeable, see previous post here

I have a Logo model which has the following fields name:string, image:string, default:boolean

I am using the carrierwave gem to upload an image to the image:string column. app/models/logo.rb

class Logo < ActiveRecord::Base
mount_uploader :image, LogoUploader
scope :default, where(default: true)

def falsify_all_others
  Logo.where('id != ?', do |item|
    item.default = false

I have a logos controller, seen here app/controllers/logos_controller.rb

class LogosController < ApplicationController
def new

def create
  @logo =[:logo])
    redirect_to logos_path, :notice => "Logo has been uploaded successfully"
  render "new"

def edit
  @logo = Logo.find(params[:id]) 

def destroy
  @logo = Logo.find(params[:id])
  flash[:notice] = "Logo has been obliterated!"
  redirect_to logos_path

def update
  @logo = Logo.find(params[:id])

  if @logo.update_attributes(params[:logo])
    flash[:notice] = "Logo has been changed successfully!"
    redirect_to logos_path
    flash[:alert] = "Logo has not been updated."
    render :action => "edit"

def show
  @logo = Logo.find(params[:id])

def index
  @logos = Logo.all

and my applications controller


before_filter :get_logo

def get_logo
  @logo_default = Logo.default

So, once they have created/uploaded a few images through carrierwave, I display the logo like this: app/views/logos/show.html.erb

<%= image_tag @logo.image_url.to_s %>

I want to add the default logo (which I find through my logos scope) to display on the home page. Right now, it is done through the app/assets/stylesheets/styles.scss.erb through this code

section#header {
height: 220px;
position: relative;
h1 {
    background-image: url('<%= asset_path 'logo.png' %>');
    position: absolute;
    width: 412px;
    height: 188px;
    z-index: 999;

So my question is this: Do I need to pull the code that displays the logo out of the scss.erb and add to to the app/views/layouts/application.html.erb, or can I change it in the scss? like replace asset_path with an image_tag, or something like that? Let me know if you need more info/code i'll be happy to provide... Thanks in advance


I would recommend not to put it in the scss, because you'll likely want to precompile all this static stuff in production.

Need Your Help

Django: AJAX/jQuery in Admin

jquery ajax django django-admin

I have a Contract class where contract_mod allows to extend a contract from a previous one. contract_mod should only show contracts related with the person that we selected previously. As I've neve...

Apply hover out ease effect using css animation

html css css3 animation css-transitions

On this LIVE DEMO you can see how animation works in each div moves its image and gives opacity:1 to text.