{"id":9969,"date":"2024-03-28T04:12:20","date_gmt":"2024-03-28T04:12:20","guid":{"rendered":"https:\/\/www.bacancytechnology.com\/qanda\/?p=9969"},"modified":"2024-03-28T04:12:20","modified_gmt":"2024-03-28T04:12:20","slug":"create-new-rails-app-with-slim-template-as-default","status":"publish","type":"post","link":"https:\/\/www.bacancytechnology.com\/qanda\/ruby-on-rails\/create-new-rails-app-with-slim-template-as-default","title":{"rendered":"How to Create a New Rails App With a Slim Template As Default?"},"content":{"rendered":"<p>This Ruby script automates several tasks related to managing dependencies and converting ERB templates to Slim templates within a Rails application. <\/p>\n<p>Firstly, it defines a method do_bundle which ensures that dependencies are installed using Bundler.with_unbundled_env before executing bundle install.<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.bacancytechnology.com\/qanda\/wp-content\/uploads\/2024\/03\/carbon-1.png\" alt=\"Rails application\" width=\"650\" height=\"693\" class=\"alignnone size-full wp-image-9970\" srcset=\"https:\/\/www.bacancytechnology.com\/qanda\/wp-content\/uploads\/2024\/03\/carbon-1.png 650w, https:\/\/www.bacancytechnology.com\/qanda\/wp-content\/uploads\/2024\/03\/carbon-1-281x300.png 281w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>The script then announces the commencement of applying Slim templating, appending the slim-rails gem to the Gemfile, and injecting <strong>html2slim-ruby3<\/strong> gem within the development group, alongside a descriptive comment. Following this, it executes the do_bundle method to install dependencies. <\/p>\n<p>Next, it employs conversion commands (erb2slim) to transform layout files (application.html.erb, mailer.html.erb, and mailer.text.erb) into Slim templates, all while utilizing the -d flag to indicate a dry run. Additionally, it runs RuboCop with autocorrection enabled (-AS) to ensure code quality.<br \/>\nFinally, it outputs a message confirming the successful switch to Slim templating.<br \/>\nStore above file in your local system as ruby file and You can use this template while creating new application as below<\/p>\n<p><code>rails new blog -m ~\/slim_template.rb<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This Ruby script automates several tasks related to managing dependencies and converting ERB templates to Slim templates within a Rails application. Firstly, it defines a method do_bundle which ensures that dependencies are installed using Bundler.with_unbundled_env before executing bundle install. The script then announces the commencement of applying Slim templating, appending the slim-rails gem to the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9971,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[11],"tags":[],"class_list":["post-9969","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ruby-on-rails"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/9969"}],"collection":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/comments?post=9969"}],"version-history":[{"count":2,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/9969\/revisions"}],"predecessor-version":[{"id":9973,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/9969\/revisions\/9973"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/media\/9971"}],"wp:attachment":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/media?parent=9969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/categories?post=9969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/tags?post=9969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}