Skip to content

Instantly share code, notes, and snippets.

@externvoid
Created January 9, 2018 07:55
Show Gist options
  • Select an option

  • Save externvoid/1b09cee55eee1a7e0f277ccb362d23c9 to your computer and use it in GitHub Desktop.

Select an option

Save externvoid/1b09cee55eee1a7e0f277ccb362d23c9 to your computer and use it in GitHub Desktop.
初めてのActiveRecord
require 'active_record'
require 'pp'
ActiveRecord::Base.establish_connection(
adapter: "sqlite3",
database: "./yatoday.db"
)
class Code < ActiveRecord::Base
self.table_name = "Code2018_01_05"
self.primary_key = "code"
end
users = Code.select('code, company')
# users = Code.all
pp users.first.code
pp users.first.company
# 参考url
# https://qiita.com/gctfuji/items/80625a75959591c2b7cd
# https://railsguides.jp/active_record_basics.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment