Skip to content

Instantly share code, notes, and snippets.

View thaichors3000's full-sized avatar
🏠
a new challenge is on the way....

Thaichor Seng thaichors3000

🏠
a new challenge is on the way....
  • Phnom Penh, Cambodia
  • 03:23 (UTC +07:00)
  • LinkedIn in/thaichor
View GitHub Profile
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]
@thaichors3000
thaichors3000 / base_form.rb
Created January 31, 2020 10:01
Rails Service Design Patterns - Form Object - BaseForm
class BaseForm
include ActiveModel::Model
def persisted?
false
end
def save
return false unless valid?