Skip to content

Commit

Permalink
make picture controller inherit from new crud controller instead of a…
Browse files Browse the repository at this point in the history
…pi crud controller
  • Loading branch information
RandomTannenbaum committed Mar 12, 2024
1 parent 67ea46c commit 44c03ad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions app/controllers/crud_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@ def error_messages
# rubocop:enable Rails/OutputSafety
end

def get_asset_path(filename)
manifest_file = Rails.application.assets_manifest.assets[filename]
if manifest_file
File.join(Rails.application.assets_manifest.directory, manifest_file)
else
Rails.application.assets&.[](filename)&.filename
end
end

# Class methods for CrudActions.
class << self
# Convenience callback to apply a callback on both form actions
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/people/picture_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module People
class PictureController < Api::CrudController
class PictureController < CrudController

self.permitted_attrs = %i[picture]

Expand All @@ -17,6 +17,10 @@ def show

private

def model_class
Person
end

def person
@person ||= Person.find(params[:id])
end
Expand Down

0 comments on commit 44c03ad

Please sign in to comment.