Class: RailsDevtools::Routes::RouteDetails::ControllerCard

Inherits:
Components::ApplicationComponent show all
Defined in:
app/views/rails_devtools/routes/route_details/controller_card.rb

Instance Method Summary collapse

Methods inherited from Components::ApplicationComponent

#before_template

Constructor Details

#initialize(controller_info:) ⇒ ControllerCard

Returns a new instance of ControllerCard.



6
7
8
# File 'app/views/rails_devtools/routes/route_details/controller_card.rb', line 6

def initialize(controller_info:)
  @controller_info = controller_info
end

Instance Method Details

#view_templateObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/views/rails_devtools/routes/route_details/controller_card.rb', line 19

def view_template
  div(class: card_class) do
    div(class: "card-body") do
      div(class: text_class) do
        div(class: "flex items-center ") do
          if error?
            span(class: "mr-1") do
              render Components::Lucide::TriangleAlert.new(width: 16, height: 16)
            end
          end
          h4(class: "font-bold") { full_class_name }
        end
        span(class: "italic") { action }
      end

      if error?
        ul(class: "text-sm text-error mt-2") do
          if controller.nil?
            li { "No controller found for this route." }
          else
            li { "No action ##{action} found in associated controller." }
          end
        end
      end

      div(class: "card-actions justify-end mt-8") do
        controller_file_path_input
      end
    end
  end
end