I still don’t have an official name for this project, so I’ll call it “bakery” in the interim.
rails bakery git add bakery git commit -a -m "Basic Rails install" rails server
This is new: there’s a single execution point for rails tasks. It’s nice to not have to type
script/... all the time
Fire up http://0.0.0.0:3000/ and see that it’s working.
sudo gem update haml
Add “gem haml” to Gemfile (another new feature).
Update Ryan Bates’ Nifty Generators. They’re nifty. Especially when generating.
sudo gem install nifty-generators
Add “gem nifty-generators” to the Gemfile.
Time to get a Hello World going. It’s not working until I see Hello World.
First, unpack the gems. How do I do that again?
rake -T gem /Users/craig/Documents/SoftCraft/projects/bakery/rails/bakery/db/schema.rb doesn't exist yet. Run "rake db:migrate" to create it then try again. If you do not intend to use a database, you should instead alter /Users/craig/Documents/SoftCraft/projects/bakery/rails/bakery/config/boot.rb to limit the frameworks that will be loaded
rake db:migrate (in /Users/craig/Documents/SoftCraft/projects/bakery/rails/bakery)
rake -T gem (in /Users/craig/Documents/SoftCraft/projects/bakery/rails/bakery) rake rails:freeze:gems # The rails:freeze:gems is deprecated, please use bundle install instead
More Rails 3 changes. Looks like freezing isn’t necessary any more. That’s good; I never liked it anyway.
Now, I need a “Hello World” page. That means I need a HomeController for the root route.
rails generate controller Home
Now I need a view. Since Home is a singleton controller, that’s the
show view. Whip up Add
views/home/show.haml and dump in
Now I need a route. In the new Rails 3 routing DSL that’s done by:
root :to => "home#show"
Lastly, I need to delete
Hit localhost:3000 and it works!
Looks like Shoulda isn’t Rails 3 compatible yet.
DEPRECATION WARNING: RAILS_ROOT is deprecated! Use Rails.root instead. (called from join at /Users/craig/.bundle/ruby/1.8/bundler/gems/shoulda-b8b6cad61981d47356de06c2a5586e281938c94e-rails3/lib/shoulda/autoload_macros.rb:40) /Users/craig/.bundle/ruby/1.8/bundler/gems/shoulda-b8b6cad61981d47356de06c2a5586e281938c94e-rails3/lib/shoulda/autoload_macros.rb:40:in `join': can't convert #
into String (TypeError) from /Users/craig/.bundle/ruby/1.8/bundler/gems/shoulda-b8b6cad61981d47356de06c2a5586e281938c94e-rails3/lib/shoulda/autoload_macros.rb:40:in `autoload_macros'
I go to report this bug. Of course, when I register with RailsPlugins, I get this:
We are sorry to say that something in our code went bang!
Screw it, I’ll avoid Shoulda in the interim. Instead, I’ll create a regular Test::Unit controller test.