In this post, I try to explain scaffolding in rails shortly. Firstly, Let’s create rails project

1
2
rails new blogging
cd blogging

Now, we created rails project and enter inside of project. We need to create scaffold,

1
rails generate scaffold Information first_name second_name date_time:date city:boolean
  • We create Information model, in this model
  • Type of first_name and second_name is string.
  • Type of date_time is date, this provide to create date.
  • Type of city is boolean, this provide to create checkbox.

then we need to migrate for this reason,

1
rake db:migrate

Then, If you want change your home page(index.html), you should open in your app,

config/routes.rb

this path and write

root :to => 'information#index'

save and run

1
rails s

opened http://localhost:3000/

That’s all.

Comments