Follow Along as I Stumble on the Path to Learning RoR

Posts tagged “css

NoMethodError undefined method `[]’ for “image”:Sass::Script::Value::String

When upgrading my Rails app to 4 (from 3), I was getting the error:

NoMethodError undefined method `[]’ for “image”:Sass::Script::Value::String

Eventually I found out that the asset-path / asset-url methods changed to only accept one argument.

For example,

asset-url(‘profile.png’, image)

now should be:


In my particular case, this code was in some of my css files.

ActiveAdmin Translation Missing Error

I was receiving a translation missing message that was showing up on my page views for my ActiveAdmin page.  To correct this, I found the solution on Stack Overflow which said that these translations were just missing from my en.yml file in locales, and to replace my existing one with the one here (that ActiveAdmin uses):

Referencing an Image from CSS File in Asset Pipeline

In order to reference an image from the CSS file, I added .scss at the end of the .css file and referenced the image using this syntax:

background: url(asset-path(“example.png”,image)) no-repeat; 

Internet Explorer is a Hideous Beast (but I still need to accommodate it)

I found out [rudely] what a hideous beast Internet Explorer is one day when opening my app in IE7.  I could hardly recognize my app – yes the text matched, but styles were changed, fonts didn’t work, colors were wrong, corners were right angles, buttons were too big….

While some things can be adjusted to match (or look similar) in Chrome, Firefox and Internet Explorer, there are things that will just not look (or work) the same, no matter how hard you try.  IE has just lagged so far behind the other browsers in terms of style.  I ended up having to create alternate versions of parts of my views depending on the browser.

Luckily for me, I found the browser gem which detects the browser the user is using for you.

As mentioned by Nando Vieira, who created the gem, you can then do things like:

<% if browser.ie6? %>
  <p>Your're running an older IE version. Please update it!</p>
<% end %>

For me, I had to implement it a little differently than the gem instructions say, to make it work.  Instead of:

require "rubygems"
require "browser"

I put this in the application_controller:

before_filter :current_browser def current_browser   @browser = => request.user_agent) end

then I was able to use browser detection throughout my app.

Sliding Panel

I implemented a sliding panel where users could click a link and see links to FAQs.  I was able to implement it in just a few minutes using this awesome demo and tutorial by John Phillips:

Sliding panels are a great way to save space on pages, yet make info or a form easily available to your users (with no page refresh).

Pricing Table

I needed help in creating a pricing table, and I found my answer on codrops:

Great examples and options for creating a pricing table for your app.