Posts

Showing posts from May, 2012

Rails - to create a blog site Part 2

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


Rails - to create a blog site Part 1

Image
Tutorial that I am following is from this site : http://guides.rubyonrails.org/getting_started.html


I choose to sudo as root to avoid the permission issue.
$ sudo su
Install Ruby
$ apt-get install rubygems
Install Rails
$ gem install rails
Create a blog application
$ rails new blog
Note : You might encounter this error.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
To solve this, install sqlite before create the blog application.
$ apt-get install libsqlite3-dev
$ gem install sqlite3 -v '1.3.6'
Create a database
$ rake db:create
You might encounter this error.
rake aborted! Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
Go to the created blog directory. Edit this file : Gemfile.
Uncomment this line :
gem 'therubyracer', :platform => :ruby Run this (installing nodejs and also reinstall rails) :
$ apt-get install nodejs
$ bundle install
To start the web server
$ rails…