' + post_title + '

Setting up Devise for authentication with Haml


gem "devise"
rails generate devise:install

After the generate:

Some setup you must do manually if you haven't yet:
  1. Setup default url options for your specific environment. Here is an
     example of development environment:
       config.action_mailer.default_url_options = { :host => 'localhost:3000' }
     This is a required Rails configuration. In production it must be the
     actual host of your application
  2. Ensure you have defined root_url to *something* in your config/routes.rb.
     For example:
       root :to => "home#index"
  3. Ensure you have flash messages in app/views/layouts/application.html.erb.
     For example:
       <p class="notice"><%= notice %></p>
       <p class="alert"><%= alert %></p>
  4. If you are deploying Rails 3.1 on Heroku, you may want to set:
       config.assets.initialize_on_precompile = false
     On config/application.rb forcing your application to not access the DB
     or load models when precompiling your assets.
rails generate devise User
rake db:migrate

To see the routes:

rake routes

In order to see and edit the devise views:

rails generate devise:views

To convert the newly created devise ERB views to haml first make sure the following are installed:

gem install haml
gem install hpricot
gem install ruby_parser

Make haml from ERB files:

for i in `find app/views/devise -name '*.erb'` ; do html2haml -e $i ${i%erb}haml ; done

Remove old ERB files:

for i in `find app/views/devise -name '*.erb'` ; do rm $i ; done

One Response to “Setting up Devise for authentication with Haml”

  1. Bas said:

    Jun 14, 12 at 9:52 am

    Thanks for sharing, this worked perfectly!

Leave a Reply

Fatal error: Cannot redeclare store_key() (previously declared in /home/content/21/8281521/html/wp-content/themes/vesper/footer.php(9) : eval()'d code:36) in /home/content/21/8281521/html/wp-content/themes/vesper/footer.php(21) : eval()'d code on line 2