Class: Admin::ArticlesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::ArticlesController
- Defined in:
- docs/api/stubs/generated_app.rb
Overview
What spin run gen writes into gen/concerns.rb for a controller that
includes a concern (here include AdminGate in module Admin; class
ArticlesController < ApplicationController, below one before_action
of its own). The class is reopened (inside its modules) with a
forwarder per class_methods method, then the concern’s included
body, as written, between
concern_insert_at and
concern_insert_done, so its
callbacks run where the include line is:
module Admin
class ArticlesController
def self.per_page(...) = AdminGate.per_page(...)
# AdminGate (include AdminGate at app/controllers/admin/articles_controller.rb:4)
concern_insert_at(1, 0)
before_action :require_admin
rate_limit to: 30, within: 60, by: :account_key, unless: :admin?, name: "admin"
helper_method :admin?
layout "admin", except: [:show]
concern_insert_done
end
end
gen/controllers.rb adds the concern’s callback methods to the class’s
run_callback table (with the with: methods of rate_limit lines),
writes #rate_limit_key and #rate_limit_condition? for their by:
and if: / unless: methods, and adds the ivars its methods assign to
view_assigns; for the helper_method names of the class and of the
concerns it includes, it writes #helper_method? and
#call_helper_method; for the layout lines of the class and of its
concerns’ included blocks, it writes #controller_layout (here
AdminGate’s layout "admin", except: [:show], then the class’s own
layout :choose_layout below the include, choose_layout being a
method of the controller that returns a layout name, false or nil).
Class Method Summary collapse
-
.per_page ⇒ Integer
Forwards to AdminGate.per_page:
self.class.per_pagein an action.
Instance Method Summary collapse
-
#controller_layout(layout_action__) ⇒ String
The layout the action renders in: the
layoutlines in order (a concern’s at itsincludeline), the first that applies to the action winning, else the parent’s (super).
Class Method Details
.per_page ⇒ Integer
Forwards to AdminGate.per_page: self.class.per_page in an action.
1132 |
# File 'docs/api/stubs/generated_app.rb', line 1132 def self.per_page(...) = AdminGate.per_page(...) |
Instance Method Details
#controller_layout(layout_action__) ⇒ String
The layout the action renders in: the layout lines in order (a
concern’s at its include line), the first that applies to the
action winning, else the parent’s (super). layout "x" is
"layouts/x", layout false "" (none), and layout :m m’s value
(a name; false for none; nil for the parent’s). The parameter and
locals have names no application method has.
1143 1144 1145 1146 1147 1148 1149 1150 |
# File 'docs/api/stubs/generated_app.rb', line 1143 def controller_layout(layout_action__) if layout_action__ != "show" return "layouts/admin" end layout_chosen__ = choose_layout return super if layout_chosen__.nil? layout_chosen__ == false ? "" : Cybertrain::Controller.layout_path(layout_chosen__.to_s) end |