Install slim in the app folder.
gem install slim
Now it seems that slim files with the extension .html.slim will be converted as .html.erb that you usually use.
gem install html2slim
With this, it seems that it will be possible to convert from html.erb → html.slim.
bundle exec erb2slim app/views app/views
If you get an error with this, add the following two statements to the gemfile and install bundle.
This will delete the erb file that was originally in the view folder. *If there is no file with the extension .erb, skip it.
bundle exec erb2slim app/views app/views -d
In order to automatically create a slim file in the future, OK if you specify slim in config in config/application.rb as follows.
module App class Application <Rails::Application config.generators.template_engine = changed to :slim #slim end end
Preparation before displaying #slim file
rails g controller tweets
Inside the view folder, there is a tweets folder. In it, create a new file called index.html.slim. Write something in the file for easy understanding.
Add an index action in the controller.
class ArchivesController <ApplicationController def index end end
Next is routing.
Rails.application.routes.draw do root "tweets#index" end
Restart the server and view the page
Don’t forget to restart the server. If you do not restart, you will get an error such as “ArchivesController#index is missing a template for request formats: text/html”.