diff --git a/app/controllers/friendships_controller.rb b/app/controllers/friendships_controller.rb index 5d6a280..7615b1e 100644 --- a/app/controllers/friendships_controller.rb +++ b/app/controllers/friendships_controller.rb @@ -1,4 +1,5 @@ class FriendshipsController < ApplicationController + before_action :require_login before_action :set_friendship, only: [:show, :destroy] def index diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..4b0e707 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,16 @@ module ApplicationHelper + def bootstrap_class_for(flash_type) + bootstrap_classes[flash_type] || flash_type.to_s + end + + private + + def bootstrap_classes + { + 'alert' => 'alert-warning', + 'error' => 'alert-danger', + 'notice' => 'alert-info', + 'success' => 'alert-success' + } + end end diff --git a/app/views/application/_flash_messages.html.erb b/app/views/application/_flash_messages.html.erb new file mode 100644 index 0000000..bc80ed9 --- /dev/null +++ b/app/views/application/_flash_messages.html.erb @@ -0,0 +1,9 @@ +<% flash.each do |type, message| %> +
+ + <%= message %> +
+<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index dfedfc2..ce34f14 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -35,6 +35,7 @@
+ <%= render 'flash_messages', flash: flash %> <%= yield %>