Skip to content

Instantly share code, notes, and snippets.

@a-suenami
Created November 25, 2015 10:22
Show Gist options
  • Select an option

  • Save a-suenami/f288e9be54b0584ffd5c to your computer and use it in GitHub Desktop.

Select an option

Save a-suenami/f288e9be54b0584ffd5c to your computer and use it in GitHub Desktop.
class SampleService
extends ActiveModel::Model
validates :name, presence: true
def initialize(attributes)
# ...
end
def run!
return false if invalid?
Sample.create!(attributes)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment