Skip to content

Commit

Permalink
Pages controller to show only projects with phases
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasdrga committed Jun 24, 2024
1 parent 4af09d3 commit 9b09d5e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Admin::PagesController < AdminController

def index
@pages = Page.includes(phase: :project).order(id: :desc)
@projects = @pages.map { |page| page.phase.project }.uniq
@projects = @pages.map { |page| page.phase&.project }.uniq
end

def show
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def up
Phase.find_each do |phase|
if phase.published_revision.present?
published_revision = phase.published_revision
published_revision.update_attributes(was_published: true, published_at: published_revision.updated_at)
published_revision.update_attributes!(was_published: true, published_at: published_revision.updated_at)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20240621112043_add_phase_to_pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def change
Project.find_each do |project|
project.phases.find_each do |phase|
phase.revisions.find_each do |phase_revision|
phase_revision.revision.page.update(phase_id: phase.id)
phase_revision.revision.page.update!(phase_id: phase.id)
end
end
end
Expand Down

0 comments on commit 9b09d5e

Please sign in to comment.