GeekedOut
GeekedOut

Reputation: 17185

Ruby on Rails with Haml - how to switch from erb

I am in the process of switching to HAML from erb files. I added the haml gem to my system. I created the app/views/layouts/application.html.haml file. Should I just delete the application.html.erb file?

Also, there is still the /public/index.html file which gets rendered as the default page. I want to make my own default index.html.haml page. Where do I place it and how do I make the system render that file instead of the default index file?

Thanks!

Upvotes: 5

Views: 3522

Answers (2)

Yuri  Barbashov
Yuri Barbashov

Reputation: 5437

u can autoconvert and delete all erb files using this script

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

And simply delete index.html in public folder

Upvotes: 3

MrDanA
MrDanA

Reputation: 11647

Yes you can just delete the ERB version of any views you have converted over to HAML.

As for your other question, delete the public/index/html file. Next, you may want to add a PagesController and have an action in there like index, and a corresponding view, and put your "home page" stuff in there.

Then in your routes file, add:

root :to => "pages#index"

Upvotes: 5

Related Questions