class Child
has_many :toys
end
class Toys
belongs_to :child
end
class CreateToys < ActiveRecord::Migration[5.1]
def change
create_table :toys do |t|
t.integer :child_id
関連するテーブルが2つあり、親オブジェクトの+/-%5のtshirts(子テーブル)の長さ属性に基づいてフィルタを適用したいStudentのheight属性 残念ながら、親テーブルの名前に未定義のメソッドエラーが発生します。 DBテーブル: Student
------
id
name
height
Tshirt
------
id
color
student_id
leng
私はUserモデルとShopモデルを持っています。私は1つのショップしか作成できないようにしたい。だから私のUserモデル class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable a
が作成したポストをCRUDする複数のユーザー私はユーザーという名前の2つのモデルがあり、ポスト User.rb class User < ApplicationRecord
has_many :posts
end
Post.rb class Post < ApplicationRecord
belongs_to :user
end
今のところ、ユーザーは特定の投稿を
私は、Railsプロジェクトで既定の式を持つ従来のテーブルを持っています。この式は、ランダムな4桁の数字を選択して文字列に変換します。私は、デフォルト式を設定することはpsqlにこの正確な文を入力してきた私のテスト中に:私は\d ownersを行う際 alter table owners alter column signing_code set default
substring(to_cha