Install Ruby on Rails on CentOS

Install Ruby

 yum install ruby

install Ruby dependancies.

yum install gcc g++ make automake autoconf curl-devel openssl-devel zlib-devel httpd-devel apr-devel apr-util-devel sqlite-devel
yum install ruby-rdoc ruby-devel

Install Ruby Gems

yum install rubygems

Install Rails

gem update
 gem update --system

then install rails

gem install rails

for check version try

gem install rails -V

Add column to model, ruby on Rails

add category_id column to posts table

rails g migration add_category_id_to_posts category_id:integer

You ought to edit automatically generated migration and add line on the end of change method:

add_index :posts, :category_id
then run : rake db:migrate

----------------------------
if there is aproblem in saving new fields to database 

you must permit it in the controller

like this

def user_posts_params

params.require(:user_posts).permit(:user_id, :category_id)

end

and this in the model 

attr_accessible :user_id, :category_id