How to Create Custom Scaffold Templates in Ruby on Rails
Web-Crunch
Hi, My name is Andy Leverenz and I work as a Product Designer at Dribbble. For fun, I design, code, and write. Check out my blog called Web-Crunch https://web-crunch.com where I publish design and development tutorials with the occasional vlog.
====================
Ruby on Rails is such a powerful framework. It has its own CLI of which harnesses what are known as "generators". These generators can quickly scale up resources for your app with a few keystrokes. In this post learn how to create custom scaffold templates in Ruby on Rails
Conventions get you far
Having made quite a few brand new Ruby on Rails apps in my time I always find the default look and feel of scaffolding out a resource a bit lackluster. By default, Rails generates a ton of files and stylesheets associated with a given model you pass on the command line when creating a new "scaffold".
Example:
$ rails generate scaffold Post title:string body:text
The command above will create an entire CRUD-like concept around the Post
model in a given rails application. To do this it generates a number of files which include everything from stylesheets to test-specific files. It also creates an Active Record migration file which will later be migrated into a database. This ultimately means a new table is born called posts
.
This concept is a huge time saver. This is especially true if you're just prototyping an idea or testing a theory.
Extending conventions
Within a typical scaffold, you get an entire view folder with associated views for the restful routing that gets created.
app/views/posts/_form.html.erb app/views/posts/edit.html.erb app/views/posts/index.html.erb app/views/posts/new.html.erb app/views/posts/show.html.erb
Here we get the bare bones views with the logic they need to make the app work as intended. Having run so many scaffolds in my time I've come to realize I hate the default look and feel. Can this be changed? The answer to that is YES!
Continue reading here: https://web-crunch.com/how-to-create-custom-scaffold-templates-in-ruby-on-rails
====================
π° Subscribe: https://www.youtube.com/user/webcrunchblog?sub_confirmation=1
ππ€ NEW COURSE: HELLO RAILS - Get notified https://hellorails.io
π» Previously published at: https://web-crunch.com/how-to-create-custom-scaffold-templates-in-ruby-on-rails
π» Check out the blog: https://web-crunch.com
π¦ Check out my personal site: https://justalever.com
π Links: Weekly Newsletter: https://web-crunch.com/subscribe Twitter: https://twitter.com/webcrunchblog Twitter(Personal Account): https://twitter.com/justalever Facebook: https://facebook.com/webcrunchblog Dribbble: https://dribbble.com/justalever Github: https://github.com/justalever Medium: https://medium.com/the-web-crunch-publication
πCheck out my book on UX Design: "LUXD: Learn User Experience Design" https://web-crunch.com/books/luxd
π Check out my FREE book on Tumblr Theming: "Pro Tumblr Theming" https://web-crunch.com/books/ptt
π― Need awesome web hosting? Check out cloudways. They allow me to use a variety of hosting providers and build apps with ease: http://bit.ly/webcrunchhosting
π Need more advanced hosting for Rails, PHP, Node, or other projects? Digital Ocean has you covered. https://m.do.co/c/ee243ee15648
π Ruby on Rails devs, Try HatchBox.io. You'll save upwards of 50% compared to Heroku. I use it and love it! https://hatchbox.io/?via=andy
βοΈ Or buy me a coffee https://www.buymeacoffee.com/webcrunch ... https://www.youtube.com/watch?v=BTW3MSkX6O0
57686566 Bytes