Yu-Chieh’s Blog (Y.C. Chang)

Ruby on Rails / Rubygems / FullStack / Git / Mac notes.

Rails Scaffold Create .erb Rather Thean .haml After Bundling Rails-haml Gem

  • After bundling ‘rails-haml’ gem, all views generated by scaffold are .haml. If we want to use default .erb views file, we need to append the folowing lines in your config/application.rb file or in config/enviroments/developement.rb.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# application.rb
...
module Events
  class Application < Rails::Application

....
# append to here
    config.generators do |g|
       g.template_engine :erb
    end
....

  end
end
...

or

1
2
3
4
5
6
7
8
9
10
11
12
13
# developement.rb
Events::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
........

  config.generators do |g|
    g.template_engine :erb # or :haml if you prefer .haml
  end

........
  # Raises error for missing translations
  # config.action_view.raise_on_missing_translations = true
end

Comments