Tag Archives: rails

Rails: model conception

You should create new model for each table:
rails generate model Tank

it'll create migration Tanks, you should open db/migrate/${date}_create_tanks.rb

and put there definition of table

After you should open model  app/models/tank.rb

and put there tables relations.

After creating models you should use RAILS_ENV=development rake db:migrate for creating database with tables and relations between the last one

Rails: dump db schema from mysql

gem install mysql2

edit config/database.yml

    adapter: mysql2
    encoding: utf8
    database: db_name
    username: user_name
    password: password_of_user
    host: host_ip
    timeout: 5000

edit Gemfile

gem 'mysql2'

bundle install

rake db:schema:dump

db/schema.rb has been created

Ruby: hessian client

gem 'hessian2', :git => 'git://github.com/takafan/hessian2.git'


    client = Hessian2::HessianClient.new('')
    client.user = 'username'
    client.password = 'password'
    result = client.getAllShards()