RailsCasts Pro episodes are now free!

Learn more or hide this

gaeldeest's Profile

GitHub User: gaeldeest

Comments by


This is certainly my favorite code excerpt:



I guess what you mean is: "how do I include /admin.js alongside my general CSS stylesheet in the admin view in a single file ?"

Your JS files aren't supposed to be regenerated every request, and won't in production - so I would discourage using Donnie's solution.

The only solution is to include your 'screen' stylesheet in your admin stylesheet and include only the 'admin' stylesheet in your layout like Dmytrii suggested.


Not tested, but I think this should work:

mount Uhoh::Engine => '/', :constraints => { :subdomain => 'uhoh' } 

You should always refresh a page before replying, just in case someone has already posted a more thorough explanation than yours :)


I think it won't be a problem. In the assets directory of the engine, the path of the image is still "uhoh/alert.png", no matter what route the engine is mounted at.


In my opinion, the two main advantages of testing are:

  • Staying focused. By writing tests upfront, and writing only the code needed to make them pass, I don't waste my time on not so important things anymore, but spend it only on things relevant to the task at hand. For this to work, you need to start with high-level tests (just like Ryan does), breaking things down into lower-level tests (model, controller) only when needed.

  • Regression testing. When you start modifying an app you haven't touched for months or even years, what's the best way to ensure you haven't broken anything ? Run the tests !

But of course, there are many others:

  • Documentation. Good, extensive testing can help other developers understand your code and contribute to the project more quickly. Even you can benefit from it.

  • Catching bugs before they even start to fly. Granted, writing tests / specs is slow. This is a feature :) It makes you think about your product twice, and you often find corner-cases you wouldn't have thought of by writing code upfront. Writing one spec, then, can lead you to write several more, which of course will all have to pass by the end of the day...

  • Dopamine. What a warm and fuzzy feeling it is to see all these green dots on the screen ! It helps you staying motivated.

I'm sure other people can think of even more benefits. Of course, there also are pitfalls, like over-testing. But with experience, you'll know when you're doing the right thing, or if something is wrong in your process.

Also, don't forget than testing really starts to pay off on big projects. What may seem useless on artificial examples or on new applications might real soon become necessary. If you start a big project without testing, you will soon regret it !

Hope this helps,



Great ! You seem to test your code pretty much like I do.

I tried to use Cucumber, I really did. But I soon realized that I spent too much time trying to write tests that read great, maintaining an horrible stack of "steps", for pretty much nothing in return.

RSpec acceptance testing is just the level of abstraction I need.


Putting this in an initializer:

require 'sass'
require 'sass/plugin'

Sass::Engine::DEFAULT_OPTIONS[:load_paths].tap do |load_paths|
    load_paths << "#{Rails.root}/my/import/path"

is supposed to work, according to many comments found on the net. Yet it doesn't - I still get an error when trying to import some external stylesheet, which incidentally outputs the SASS path, which is, indeed, app/assets/stylesheets.

I converted some Rails 3.0 application to 3.1 ; it might explain why this solution doesn't work for me.

I find it unfortunate that the Rails guys didn't think this out more thoroughly. Or may be they did, in which case I'm eagerly waiting for some detailed documentation ;)


Hi Ryan,

Nice screencast, as always. I can't say I learned much, as I've been using SASS for years now, but it's nice to have some user-friendly reference to point Rails newbies to.

What I really wanted to know though, is this: how do you set the SASS import path in Rails 3.1 ? Been trying for days, nothing seems to work.

Do you happen to know if this is possible at all ?

Thanks again