Wednesday, May 30, 2012

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<resource name>/

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

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. :)

No comments:

Post a Comment