Created
January 9, 2018 07:55
-
-
Save externvoid/1b09cee55eee1a7e0f277ccb362d23c9 to your computer and use it in GitHub Desktop.
初めてのActiveRecord
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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