Created
June 15, 2017 15:58
-
-
Save staycreativedesign/9dc57e2ecc44e4b719e4f28d326ea063 to your computer and use it in GitHub Desktop.
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
| class CreatePrivateRooms < ActiveRecord::Migration[5.0] | |
| def change | |
| create_table :private_rooms do |t| | |
| t.timestamps | |
| t.string :name | |
| end | |
| end | |
| end |
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
| Loading development environment (Rails 5.0.2) | |
| 2.4.1 :001 > PrivateRoom.create | |
| (0.2ms) BEGIN | |
| SQL (1.3ms) INSERT INTO "private_rooms" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id" [["created_at", 2017-06-15 15:58:13 UTC], ["updated_at", 2017-06-15 15:58:13 UTC]] | |
| (1.0ms) COMMIT | |
| => #<PrivateRoom id: 2, created_at: "2017-06-15 15:58:13", updated_at: "2017-06-15 15:58:13", name: nil> |
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
| class PrivateRoom < ApplicationRecord | |
| before_create :generate_link | |
| def to_params | |
| binding.pry | |
| self.name | |
| end | |
| private | |
| def generate_link | |
| binding.pry | |
| self.name = SecureRandom.hex(8).to_s | |
| end | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment