Rails power

gabrielleeaston

Gabrielle Easton

Posted on March 26, 2021

Rails power

I am impressed with what Rails can do with one command. The challenge comes with understanding what happens under the hood.

This week I tried to understand what files and functionality were created after I ran the command Scaffold. Scaffolding in Ruby on Rails refers to the automatic generation of a simple set of a model, views, and controller, usually for a single table.

Here is the command I ran:

bin/rails generate scaffold Shift shift_status:boolean role_name:string shift_start:datetime shift_end:datetime shift_pay:integer
Enter fullscreen mode Exit fullscreen mode

It created not only the model, views, and the controller, but also created test files for the models and views, a helper file for the shifts, sass files for styling, and even a ‘shifts’ resource in the routes file, which defines all possible routes for our shifts.

We can take a quick look at the routes created for us using resources by running the rails routes command.

Alt Text

Here is the view we are getting if we follow localhost:3000/shifts

Alt Text

The next step will be to add logic to controllers and association between other data(tables) in our application.

Lastly, I'd like to say a big THANK YOU to Arit, our senior engineer. I feel very supported and motivated to learn. Thank you for creating a welcoming and supportive environment.❤️

Thanks for reading!

Photo by Lopez Robin on Unsplash

💖 💪 🙅 🚩
gabrielleeaston
Gabrielle Easton

Posted on March 26, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Rails power
womenintech Rails power

March 26, 2021