Last active
December 15, 2015 04:29
-
-
Save knewter/5201992 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EmailSignupsController | |
# jQuery style: | |
def create | |
AcceptsEmailSignupForm.call(params).then(method(:successful_signup)).fail(method(:failed_signup)) | |
end | |
protected | |
def successful_signup | |
render 'email_signups/thank_you' and return | |
end | |
def failed_signup(errors) | |
render('new', errors: errors) and return | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EmailSignupsController | |
# lambda style: | |
def create | |
AcceptsEmailSignupForm.call(params, { | |
success: ->{ render('email_signups/thank_you') }, | |
failure: ->(errors){ render('new', errors: errors) } | |
}) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EmailSignupsController | |
# lambda style: | |
def create | |
AcceptsEmailSignupForm.call(params, { | |
success: method(:successful_signup), | |
failure: method(:failed_signup) | |
}) | |
end | |
protected | |
def successful_signup | |
render 'email_signups/thank_you' and return | |
end | |
def failed_signup(errors) | |
render('new', errors: errors) and return | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment