Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
a new challenge is on the way....

Thaichor Seng thaichor

🏠
a new challenge is on the way....
View GitHub Profile
View user_form.rb
class User < ApplicationRecord
has_one :car
validates :username, presence: true,
validates :username, length: { maximum: 100 }
validates :age, numericality: { only_integer: true }
end
class Car < ApplicationRecord
enum vehicle_type: %i[suv van compact]
@thaichor
thaichor / base_form.rb
Created Jan 31, 2020
Rails Service Design Patterns - Form Object - BaseForm
View base_form.rb
class BaseForm
include ActiveModel::Model
def persisted?
false
end
def save
return false unless valid?