Following the guide at http://github.com/fortuity/rails3-mongoid-devise I've managed to setup Rails3 with Haml, Devise, and Mongoi开发者_如何学Cd. (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)
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
- add the words "hello from haml" into your haml file
look at the output server output you should see something along the lines of:
Rendered home/index.html.haml within layouts/application (42.9ms)
精彩评论