diff --git a/app/controllers/cards_controller.rb b/app/controllers/cards_controller.rb
index e52926955..7f1377e17 100644
--- a/app/controllers/cards_controller.rb
+++ b/app/controllers/cards_controller.rb
@@ -1,9 +1,9 @@
require "ostruct"
class CardsController < ApplicationController
- include CollectionScoped, Collections::ColumnsScoped
+ include Collections::ColumnsScoped
- skip_before_action :set_collection, only: :index
+ before_action :set_collection, only: %i[ create ]
before_action :set_card, only: %i[ show edit update destroy ]
enable_collection_filtering only: :index
@@ -47,8 +47,12 @@ class CardsController < ApplicationController
end
private
+ def set_collection
+ @collection = Current.user.collections.find(params[:collection_id])
+ end
+
def set_card
- @card = @collection.cards.find params[:id]
+ @card = Current.user.accessible_cards.find params[:id]
end
def card_params
diff --git a/app/helpers/cards_helper.rb b/app/helpers/cards_helper.rb
index 9d332794b..cdf5c5d7b 100644
--- a/app/helpers/cards_helper.rb
+++ b/app/helpers/cards_helper.rb
@@ -49,7 +49,7 @@ module CardsHelper
end
def button_to_delete_card(card)
- button_to collection_card_path(card.collection, card),
+ button_to card_path(card),
method: :delete, class: "btn txt-negative borderless txt-small", data: { turbo_frame: "_top", turbo_confirm: "Are you sure you want to permanently delete this card?" } do
concat(icon_tag("trash"))
concat(tag.span("Delete this card"))
diff --git a/app/models/ai/list_cards_tool.rb b/app/models/ai/list_cards_tool.rb
index ec105ba73..a32456ddf 100644
--- a/app/models/ai/list_cards_tool.rb
+++ b/app/models/ai/list_cards_tool.rb
@@ -102,7 +102,7 @@ class Ai::ListCardsTool < Ai::Tool
creator: card.creator.as_json(only: [ :id, :name ]),
assignees: card.assignees.as_json(only: [ :id, :name ]),
description: card.description.to_plain_text.truncate(1000),
- url: collection_card_url(card.collection, card)
+ url: card_url(card)
}
end
end
diff --git a/app/models/ai/list_comments_tool.rb b/app/models/ai/list_comments_tool.rb
index 8bc7a875a..20fa21417 100644
--- a/app/models/ai/list_comments_tool.rb
+++ b/app/models/ai/list_comments_tool.rb
@@ -89,7 +89,7 @@ class Ai::ListCommentsTool < Ai::Tool
reacter: reaction.reacter.as_json(only: [ :id, :name ])
}
end,
- url: collection_card_url(comment.card.collection_id, comment.card, anchor: "comment_#{comment.id}")
+ url: card_url(comment.card, anchor: "comment_#{comment.id}")
}
end
end
diff --git a/app/models/card/promptable.rb b/app/models/card/promptable.rb
index b9a00597e..c0374759b 100644
--- a/app/models/card/promptable.rb
+++ b/app/models/card/promptable.rb
@@ -27,7 +27,7 @@ module Card::Promptable
* Collection id: #{collection_id}
* Collection name: #{collection.name}
* Number of comments: #{comments.count}
- * Path: #{collection_card_path(collection, self, script_name: Account.sole.slug)}
+ * Path: #{card_path(self, script_name: Account.sole.slug)}
END OF CARD #{id}
PROMPT
diff --git a/app/models/comment/promptable.rb b/app/models/comment/promptable.rb
index eb11fde80..93c931432 100644
--- a/app/models/comment/promptable.rb
+++ b/app/models/comment/promptable.rb
@@ -20,7 +20,7 @@ module Comment::Promptable
* Card title: #{card.title}
* Created by: #{creator.name}}
* Created at: #{created_at}}
- * Path: #{collection_card_path(card.collection, card, anchor: ActionView::RecordIdentifier.dom_id(self), script_name: Account.sole.slug)}
+ * Path: #{card_path(card, anchor: ActionView::RecordIdentifier.dom_id(self), script_name: Account.sole.slug)}
END OF COMMENT #{id}
PROMPT
end
diff --git a/app/models/notification_pusher.rb b/app/models/notification_pusher.rb
index 6fd81e0a5..b5926e2be 100644
--- a/app/models/notification_pusher.rb
+++ b/app/models/notification_pusher.rb
@@ -113,6 +113,6 @@ class NotificationPusher
end
def card_path(card)
- "#{account_prefix}#{collection_card_path(card.collection, card)}"
+ "#{account_prefix}#{Rails.application.routes.url_helpers.card_path(card)}"
end
end
diff --git a/app/views/cards/container/_image.html.erb b/app/views/cards/container/_image.html.erb
index b38f05c07..de2341aa1 100644
--- a/app/views/cards/container/_image.html.erb
+++ b/app/views/cards/container/_image.html.erb
@@ -4,7 +4,7 @@
Remove background image
<% end %>
<% elsif !card.closed? %>
- <%= form_with model: card, url: collection_card_path(card.collection, card), data: { controller: "form" } do |form| %>
+ <%= form_with model: card, url: card_path(card), data: { controller: "form" } do |form| %>