0

In my current project I used to use erb as the default view template, then I decided to switch to slim, so I used tools to convert all the .erb files to .slim files.

Now I have erb and slim files co-exist in the same folder, the problem is after I restarted the rails server, it still rendered the old .erb files, not the .slim files as I expected.

I have already put 'gem slim-rails' in my Gemfile and updated it, so what else should I do to let Rails choose these slim templates to render instead of the erb templates?

PS: Do I have to delete all the .erb files? Because I want to keep them as a study purpose.

Andrei Botalov
  • 20,686
  • 11
  • 89
  • 123
ugoa
  • 117
  • 9

3 Answers3

0

It seems that the answer to my last question is YES, I have to delete all the .erb templates, only in this way can Rails render the .slim templates as expected.

Though I still don't know why Rails prefer erb than slim when they both exist, could it be that e in erb priors to s in slim?

ugoa
  • 117
  • 9
  • Well it is nothing like that!! Please refer to answer above by @amritdeep Dhungana – Nikhil Mar 14 '14 at 21:01
  • @Nikhil Now I know Rails better and realise this is a wrong answer. I am going to comment it out so it won't mislead other people. – ugoa Mar 18 '14 at 03:19
0

i think you can just change the name of the files which contain those erb templates, so no need to delete them. So when you want to use erb, change to original name.

Surendra Bobba
  • 476
  • 3
  • 17
0

Make this configuration in config/application.rb

class Application < Rails::Application
...............................
    config.generators do |g|
      g.template_engine :slim
    end
end
Amrit Dhungana
  • 4,371
  • 5
  • 31
  • 36