Skip to content

Improve wording on subscribers #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@
/db/**/*.sqlite3-*

.envrc

# Ignore files generated by Rubymine
.idea
.idea/*
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ GEM
PLATFORMS
aarch64-linux
arm64-darwin-22
arm64-darwin-23
x86_64-linux

DEPENDENCIES
Expand Down
10 changes: 8 additions & 2 deletions app/controllers/videos/subscribers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@ class Videos::SubscribersController < ApplicationController
def create
case subscribers_create.call
when Dry::Monads::Success
flash.now[:notice] = "You've subscribed successfully!"
add_success_message
when Dry::Monads::Failure
flash.now[:error] = "There was a problem subscribing you! #{subscriber.errors.full_messages.join(', ')}"
add_error_message
end
end

private

def subscribers_create = Subscribers::Create.new(subscriber:, list:, unsubscribe_url:)

def add_success_message = flash.now[:notice] = t(".success_message")

def add_error_message = flash.now[:error] = t(".error_message", error_messages:)

def error_messages = subscriber.errors.full_messages.join(", ")

def unsubscribe_url = new_videos_unsubscribe_url

def subscriber = @_subscriber ||= Subscriber.new(subscriber_params)
Expand Down
6 changes: 6 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@

en:
hello: "Hello world"

videos:
subscribers:
create:
success_message: "You've subscribed successfully!"
error_message: "There was a problem subscribing you! %{error_messages}"