Rails - to create a blog site Part 2

Creating a resource.

The format used is as follow :

$ rails generate scaffold <resource name> <list of fields>

Example :
$ rails generate scaffold test_j author:string title:string tag:string content:text create_datetime:timestamp


Create associated table in the database.

$ rake db:migrate

Then you are done! This new resource can be accessed by http://0.0.0.0:3000/<resource name>/

For the example that I used, it would be http://http://0.0.0.0:3000/test_js/


Click on the New Test_j link will give you the form that we created with the one line command earlier.


Note that, the date time is showing current GMT time. I haven't figured out why/how matters. :)


Comments

Popular Posts