0 like 0 dislike
1 view
in Ruby by anonymous Bilge (165k points)
reshown by anonymous
Rails kullanmadan sadece ruby ile active record kullanabilir miyiz ?

1 Answer

0 like 0 dislike
by anonymous Bilge (165k points)
require 'rubygems'
gem 'activerecord'

require 'mysql2'
require 'active_record'

ActiveRecord::Base.establish_connection(
    :adapter => 'mysql2',
    :database => 'railsdb',
    :username => "root",
    :password => "q1",
    :socket => "/opt/lampp/var/mysql/mysql.sock"
)

class User < ActiveRecord::Base
end

def check_has_many
  u = User.new
  u.id = 1
  u.first_name = "Etki"
  u.last_name = "Tepki"
  u.save
  user = User.find(:first)
  puts user
end

check_has_many # not working
...