views:

84

answers:

1

Following the guide at http://github.com/fortuity/rails3-mongoid-devise I've managed to setup Rails3 with Haml, Devise, and Mongoid. (As a side-note, the guide is really detailed; recommended reading for new Rails users!)

Only problem is I can't get Rails to render my Haml views:

Started GET "/" for 127.0.0.1 at 2010-07-01 14:40:23 +0200
  Processing by HomeController#index as HTML
  MONGODB miabreto_development['users'].find({}, {})
Rendered home/index.html.haml within layouts/application (4.2ms)
Completed 200 OK in 21ms (Views: 21.0ms)

Note that it doesn't return a missing template error, it just renders the view as plain html. The filename follows the convention:

app/views/home/index.html.haml

and in the Gemfile I have:

# Bundle gems needed for Haml
gem 'haml', '3.0.13'
gem "rails3-generators", :group => :development

Since I am new to Rails, I am not sure what the execution path looks like for deciding what renderer to use, etc. Can someone suggest what I may have missed in my setup or where to look for errors? (This is Rails.3.beta4)

+1  A: 

Couple of things

First of all, rails will render index.html.erb if it is present in the views folder. It will do this before it renders index.html.haml. So, take a look in your views folder and if you do have a file called index.html.erb, then just delete it and rails should start doing haml for you

Secondly, even when it does render the haml version of your file, it will still read " Processing by HomeController#index as HTML"

Hope this helps, and yeah, it's a great tutorial, read it myself a few days ago

PS - two ways to tell if your template is doing haml

  1. add the words "hello from haml" into your haml file
  2. look at the output server output you should see something along the lines of:

    Rendered home/index.html.haml within layouts/application (42.9ms)

stephenmurdoch
Thanks for the informative response!1. Only have index.html.haml in the directory2. That's good to know. (I updated the question code with more output)
pithyless
i would take a guess and say that I think it is rendering haml there. It might be working ok :)
stephenmurdoch
*head-to-desk* I've figured out the User Error in question. The problem was in fact app/views/layouts/application.html.erb that was conflicting with my code. Thanks stephemurdoch for helping me figure out the issue :-)
pithyless