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

Embed HTML UI Shiny application in package

r shiny

I'm trying to include a shiny implementation in a package I'm making. I see that in shiny::runApp() you can specify the UI and server as a list rather than a directory location:

Telling my calculator to not divide by zero

c++ calculator division

I am making a calculator in C++ and it works fine except when I divide by zero. So I have an if statement saying to give the message "Error Divide buy zero" when a number is divide by zero. However...