diff --git a/Gemfile.lock b/Gemfile.lock index 6fdcb5e..99d82ef 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -371,6 +371,7 @@ GEM PLATFORMS aarch64-linux arm64-darwin-22 + arm64-darwin-23 x86_64-linux DEPENDENCIES diff --git a/app/controllers/my/favorites_controller.rb b/app/controllers/my/favorites_controller.rb new file mode 100644 index 0000000..103b8f0 --- /dev/null +++ b/app/controllers/my/favorites_controller.rb @@ -0,0 +1,5 @@ +class My::FavoritesController < ApplicationController + def index + @favorite_gemfiles = current_user.favorite_gemfiles + end +end diff --git a/app/models/user.rb b/app/models/user.rb index 7c429c5..b7e99fa 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,4 +19,8 @@ def self.from_omniauth(omniauth_params) user.save user end + + def favorite_gemfiles + Gemfile.where(id: favorites.where(favoritable_type: "Gemfile").pluck(:favoritable_id)).with_favorites + end end diff --git a/app/views/gemfiles/index.html.erb b/app/views/gemfiles/index.html.erb index a8a4ef5..8b4f333 100644 --- a/app/views/gemfiles/index.html.erb +++ b/app/views/gemfiles/index.html.erb @@ -13,7 +13,5 @@ <% end %> \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 9e1a070..041846b 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -116,9 +116,10 @@ - diff --git a/app/views/my/favorites/index.html.erb b/app/views/my/favorites/index.html.erb new file mode 100644 index 0000000..8bd17f3 --- /dev/null +++ b/app/views/my/favorites/index.html.erb @@ -0,0 +1,9 @@ +<% + title "My Favorite Gemfiles" + header_title "My Favorite Gemfiles" +%> + + diff --git a/config/routes.rb b/config/routes.rb index ea12f9d..4b7d4c1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,6 +26,10 @@ get "search", to: "search#index" + namespace :my do + resources :favorites, only: [ :index ] + end + # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. get "up" => "rails/health#show", as: :rails_health_check