Skip to content

Instantly share code, notes, and snippets.

@antonypp
Created November 4, 2013 07:45
Show Gist options
  • Select an option

  • Save antonypp/7299341 to your computer and use it in GitHub Desktop.

Select an option

Save antonypp/7299341 to your computer and use it in GitHub Desktop.
# контроллер
def create
is = InviteService.new params[:invite]
is.make_invite success: -> { flash[:notice] = "Пигласили на #{is.email}"; redirect_to invites_url },
failure: -> { flash[:error] = "Не могу пригласить"; render }
return
end
# InviteService
def make_invite success: nil, failure: nil # Спасибо Ruby 2.0 за именованные параметры
if deliver_email
success.try.call
else
failure.try.call
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment