The Archives

SEARCH

I’m Attending

CodeMash

Tag Archives: rubyonrails

How to Generate Views for Devise in HAML

Posted in: Programming by Steve on October 20, 2010

UPDATE (5/16/2011) – As Declan points out, this is no longer the case.  you can use the master of devise from github to get this functionality back.

http://fredwu.me/post/445463159/rails-use-haml-templates-with-devise

—————————

I have been moving one of my sites to a rails application, and I am using the HAML view engine to make all my templates.  I am also using Devise as my authentication gem.  I am going to be doing some customizations of the views, however, by default, devise generates the views in ERB.

This is how to get the devise generator to use a HAML template instead of ERB.

Add the following to your GEMFILE:

gem 'haml'
group :development do
  gem 'hpricot'
  gem 'ruby_parser'
end

Then execute the following statements in a terminal/command window:

bundle install
rails generate devise:views -e haml

This will create the views for devise in HAML.

Learning Ruby for the Web Presentation

Posted in: General by Steve on October 18, 2010

Ryan Briones presented “Learning Ruby for the Web” at Refresh Chicago on July 28, 2010.

Learning Ruby for the Web on Vimeo

Using Other DOCTYPEs with HAML and Rails 3

Posted in: Programming by Steve on October 15, 2010

I recently purchased a site template from ThemeForest and I wanted to use it in a brand spankin’ new Rails 3 website.  I immediately created the application and installed haml.  I had heard so much about haml that I wanted to use it with this new site.  The DOCTYPE that the template used was 1.0 Transitional:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

However, by default, Rails 3 and haml render the default DOCTYPE as HTML5, like this:

!!! # => renders as <!DOCTYPE html>

Unfortunately, even if you try to add “!!! Transitional” as documented, it will not render the correct DOCTYPE.  So in order for me to get the correct doctype, I had to add a haml.rb configuration file under /config/initializers/ with the following code at the top of the file:

Haml::Template.options[:format] = :xhtml

So now, when the application is configured to use xhtml instead of the rails 3 default of html5, we will see the correct DOCTYPE. Took me a while to figure out why my template javascript and css wasn’t working properly.

Autotest in Ruby

Posted in: Programming by Steve on September 29, 2010

Getting constant feedback on the health of your system is always a great thing.  In rails, you can install a gem called autotest that can run your tests as you change your application and let you know if you have broken anything.

All you have to do is start a terminal window, and type “autotest”.  That’s it!  You get instant feedback on your tests!

http://ph7spot.com/musings/getting-started-with-autotest

Why Ruby on Rails?

Posted in: General by Steve on September 23, 2010

Because today, Visual Studio crashed 4 times on me, Visual Basic compiler crashed and I had to force the application closed via Task Manager.

I don’t have a lot of crashes with Textmate.

Windy City Rails – A Retrospective from an Outsider

Posted in: Programming by Steve on September 13, 2010

logo.pngI could go through each session and say what I learned, but I think going to these conferences should be more about the overall impression than about the nitty gritty details.  I wanted to meet as many people as possible and take in as much information as I could.

I got to meet a lot of great people like Scott Parker, Andy Maleh, Rachel Heaton, and Nick Lewis.  But the one thing I got from the conference is that the demand for Rails developers is growing, and growing fast.  All of the companies that were there (Groupon, Obtiva, Hashrocket, etc..) were hiring new talent, which is pretty amazing considering the economy.

My thoughts are confirmed by this article by the San Francisco Chronicle.

Thanks to Ray Hightower and ChicagoRuby for putting this all together.

If you want more of a play-by-play, Nick Gauthier has a great write up on his blog. Lots of photos here as well.

Quote of the Day: “So, your corporate culture sounds great … for bachelors” – Sara Trice in response to Hashrocket presentation on Team Building

Word of the Day: “Rehacktoring” – Jake Scruggs

Interesting Note: Apple was a sponsor of the conference