diff --git a/app/controllers/cards/pins_controller.rb b/app/controllers/cards/pins_controller.rb index 6ac118543..f8da07da3 100644 --- a/app/controllers/cards/pins_controller.rb +++ b/app/controllers/cards/pins_controller.rb @@ -2,6 +2,7 @@ class Cards::PinsController < ApplicationController include CardScoped def show + fresh_when etag: @card.pin_for(Current.user) || "none" end def create diff --git a/app/controllers/cards/watches_controller.rb b/app/controllers/cards/watches_controller.rb index e1c181335..4d83567d0 100644 --- a/app/controllers/cards/watches_controller.rb +++ b/app/controllers/cards/watches_controller.rb @@ -2,7 +2,7 @@ class Cards::WatchesController < ApplicationController include CardScoped def show - fresh_when etag: @card.watch_for(Current.user) + fresh_when etag: @card.watch_for(Current.user) || "none" end def create diff --git a/app/models/card/pinnable.rb b/app/models/card/pinnable.rb index 0cdaf4000..ff3407ea0 100644 --- a/app/models/card/pinnable.rb +++ b/app/models/card/pinnable.rb @@ -9,6 +9,10 @@ module Card::Pinnable pins.exists?(user: user) end + def pin_for(user) + pins.find_by(user: user) + end + def pin_by(user) pins.find_or_create_by!(user: user) end