uninitialized constant Rails::Railtie

A few days ago my app just stopped working, after a quick google search I found a great site that explains why:

Jamie van Dyke that pointed out that inherited_resources has now fully moved to Rails 3 and will no longer work on Rails 2.3 or lower. Now Jamie seems to point to use older versions of the gem because they changed the code for Rails 3.0, however I feel that his versions aren’t the latest version you could be running. So I wanted to add my 2 cents by showing you what I use:

In my environment.rb … Continue Reading

uninitialized constant Test::Unit::TestResult::TestResultFailureSupport Error

Today trying to run my RSpec tests and I get an odd error:
uninitialized constant Test::Unit::TestResult::TestResultFailureSupport (NameError)
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:105:in `const_missing’
/usr/local/lib/ruby/gems/1.8/gems/test-unit-2.0.3/lib/test/unit/testresult.rb:28
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:158:in `require’
….
After doing some research online I found out that the issue is caused by Shoulda and Mocha being included in my app. It seems that if you put a gem dependence for Shoulda before Mocha,  you’ll get this error, so the fix is to place the gem dependence for Mocha before Shoulda.
config.gem “rspec”, :lib => false, :version => “>=1.2.6″
config.gem “rspec-rails”, :lib => ’spec/rails’, :version => “>=1.2.6″
config.gem “mocha”
config.gem “thoughtbot-shoulda”, :lib => “shoulda”, :source => “http://gems.github.com”
Hope that helps

UPDATE:

I hit the same error having … Continue Reading

Error with fsevent and autospec (on Mac)

Today I’ve upgraded my gems and noticed that when running my autospec I get an odd error:
[01:09:25 /usr/local/lib/ruby/gems/1.8/gems/ruby-ole-1.2.10/lib/ole/storage/base.rb:146:load]

WARN   root name was “R”
And my autospec would keep printing out:

sh: line 1:  6303 Trace/BPT trap          /usr/local/lib/ruby/gems/1.8/gems/autotest-fsevent-0.1.2/fsevent/darwin/fsevent_sleep ‘/Users/andrew/rails_apps/example_com’ 2>&1
sh: line 1:  6307 Trace/BPT trap          /usr/local/lib/ruby/gems/1.8/gems/autotest-fsevent-0.1.2/fsevent/darwin/fsevent_sleep ‘/Users/andrew/rails_apps/example_com’ 2>&1
Unfortunately I don’t have the time to look into the fsevent code to see if I can make a work around, however I found that you can remove the gem (’sudo gem uninstall autotest-fsevent’) and install the older version (’sudo gem install autotest-fsevent –version 0.1.1′)

Hopefully this helps someone … Continue Reading

Setting Session Cookie across your whole domain (in Rails 2.3)

I have an application that has subdomains based on account (i.e. user1.example.com) but I want one login for the whole system, no matter what subdomain/account your in. In rails 2.2 I’d set it up by setting:

ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:session_domain] = ‘.domain.com’

Notice the leading ‘.’ (very much needed)

But in rails 2.3 it doesn’t work, so I found from Mark Gandolfo you can set it using:

config.action_controller.session = {
:session_key => ‘_my_session_id’,
:secret => ‘..your_secret_code_here..’,
:domain => “.domain.com”
}

Hope that helps someone! ;)

UPDATE:

If what I’m showing here is to simple for your needs, I did find a great post on how to deal … Continue Reading

Unobtrusive Javascript Presentation

A few weeks ago I was asked if I could give a presentation at the upcoming new DemoCampMississauga and last night I got to present on Unobtrusive JavaScript. Hopefully people learned lots.

In the spirit of sharing, I want to make sure that my presentation and all the files I created are accessible to all users (whether you came to the demo camp or not).
I figured posting everything on Github was the best solution: http://github.com/anlek/unobtrusive_javascript_presentation

Also for the next month or so, I’m going to leave up the demo site that I created (from the code provided on github) to … Continue Reading

ERROR: While executing gem … (Zlib::BufError) in windows

So today I’m trying to update my gems and I get this error on random gems like rspec-rails but rspec updated fine.

I googled the issue and found great articles on the error, unfortunately none of them really worked. This brought me to posting what I did to fix it the error.

First, based on dontrepeatyourself, I updated to the latested gem system (version 1.3.3).
gem update –system
Based on what I’ve read on the site, it fixed the issue for a lot of people (keep in mind this is an article from 2007) but it didn’t fix my issue. … Continue Reading

Removing a remote git branch

I was showing someone how great git is using the new version of MSYSgit (version 1.6.2.2.1669.g7eaf8) and found out that calling git push –all will push ALL branches, even if they don’t exist on the remote server. So I ended up pushing a development branch that was very unstable and wanted to remove it. Luckily a quick google search pointed me to this great blog post: .liferc.
Reading this, very to the point, post I was a little confused on what is my repository. So I figured I’d clearify a bit by what you need to do.
Say you … Continue Reading

Rails 2.3 Templates on Windows

In Rails 2.3, templates are simple ruby files containing DSL for adding plugins, gems, initializers, etc. to your freshly created Rails project. To apply the template, you need to provide the rails generator with location of the template you wish to apply, using -m option.

Reading up on the commands in the template system and watching the railscasts.com episode, I got fired up on the possibilities of such a simple yet amazing system. So I dove in and started creating my base template. I was so excited that I write the whole template out in one go and … Continue Reading

Git branch and status info in prompt (on Windows)

Git Bash with Git Branch and Status

Git Bash with Branch and Status Info

I found this great article on Intridea Development Blog on how to put git status in your prompt window. It’s an amazingly useful addon as I often forget what branch I’m on in my project or if I changed anything. The problem is that it’s written for OSX/Linux users. So I’d like to show you what you need to do to get this same functionality in Git … Continue Reading

Everything You Know About CSS Is Wrong Review

Internet Explorer 8 being release soon and Microsoft putting in the work to make IE8 pass the Acid 2 test, SitePoint decided to write about the new way to do visual layout using CSS tables that are both easy or reliable across the the major browsers. The name of the book is Everything You Know About CSS Is Wrong by Rachel Andrew and Kevin Yank, published by SitePoint and available now.

The Book

The book comes in at 111 pages long and is as beautiful as The Principles of Beautiful Web … Continue Reading