below are some of the problems I’ve been having while following the railstutorial.org screencasts. These are in no particular order and may only pertain to my system, but I thought that I would document them here in case others run into them. Also, I’m going by the information that is provided in the screencasts themselves. During the screencasts, there are several time where the author refers to the online book in order to get the proper configuration. Most people are not going to take the time to search through the book to get the proper configuration to follow along in the screencasts. Hopefully this post will help people along when following the screencast and prevent them from having to refer to the book.
when pushing to heroku, you will receive the following error:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
checking for sqlite3.h… no
sqlite3.h is missing. Try ‘port install sqlite3 +universal’
or ‘yum install sqlite-devel’ and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
basically this means that heroku couldn’t compile the sqlite gem. You Gemfile should have the following in it if you’re following along:
source 'https://rubygems.org' gem 'rails', '3.2.5' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', :platforms => :ruby gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' # To use Jbuilder templates for JSON # gem 'jbuilder' # Use unicorn as the app server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' # To use debugger # gem 'debugger'
To fix, you need to make it so that the sqlite gem is not installed in production. to do this add change the `gem ‘sqlite3’` line in your Gemfile to the following:
gem 'sqlite3', :group => [:development, :test]
When running the tests from with ruby you receive the error `/bin/sh: rspec: command not found` Basically this is cause because you having started SublimeText from the command line and don’t have `~/bin` in your path. To add `~/bin` to your path open up your .bash_profile file in an editor. WARNING! During the installation tutorial, you installed RVM so that you can manage your ruby installation. This causes a major problem because creating a `.bash_profile` to allow you to edit your path will cause rvm to break, which will result in rails to break. In order to prevent this, YOU MUST run the rvm script from within your `.bash_profile`. Below is a fixed path and script for your .bash_profile:
export PATH=/opt/local/bin:/opt/local/sbin:$HOME/bin:$PATH [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
Depending on the installation of your system, your path could contain a bunch of stuff. Don’t worry what it looks like, just make sure you add `$HOME/bin` to the end. Now close and reopen the Terminal. Next follow the instructions here to link the `subl` executable to by issuing the following command in the Terminal window:
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
After that, you should be able to open SublimeText from a command prompt by doing `subl .`
Now when you run RubyTests it will be able to find rspec and work.
The css for the micropost is located at Listing 10.24.
A couple of weeks ago Doug Boude (rhymes with loud) authored a post about providing a service layer in CFWheels. I’m not going to go into what a service layer is or the use of it. If you want to know that, check out his post here.
Personally I never saw I use for this before. In keeping with the MVC tradition of doing thing, I always felt that these `services` could live in the model layer. However I absolutely love when people make me fall on my sword and I can clearly say that a service layer is definitely something that is needed in CFWheels. I still wouldn’t go so far as using it with a DI like WireBox, but who knows if I’ll change my mind about that later in life as well.
Following Doug’s post, I was able to implement a service layer with ease. The issue I had with his approach though was that it made testing very awkward. Having the initialization of the service layer living in the controller init method, made it a little hard to test, not impossible mind you, but a little harder then it should have been.
After giving it some thought, I figured out a way to not only make it so that the services initialized when CFWheels booted, but also was able to make the service() method global so that you can easily test against it.
If you take a look at this gist I created you’ll see the changes I made. Basically all I did was move his initServices() method into the events/onapplicationstart.cfm file and move the service() method into the events/functions.cfm file. The big change I made though was to the initServices() method so that it would automatically initialize any new services that you add to the services directory.
By putting these methods into their new homes, the services are loading once when CFWheels boots as apposed to every time a controller is created and also you’re able to access the service() method from anywhere in your application which make it easy to call in tests.
installing ruby 1.9.3 via rvm and it fails with `trucated tar archive` which you can see by going doing `more ~/.rvm/log/ruby-1.9.3-p194/extract.log`.
the simpliest way to fix this is to uninstall rvm and reinstall. you can uninstall rvm by doing `rvm implode` and install by following the installation instructions: https://rvm.io/rvm/install/
when installing xcode 3.2.6 on OS X 10.6.6 (Hazard) the installation might fail with the following error when viewing the /var/log/install.log CSSMERR_TP_CERT_EXPIRED. this is because obviously the certificate has expired and xcode can’t verify that the certificate is valid.
a quick and easy solution is to change your system data to 1/1/2012 and then perform the install.