File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
app/lib/matestack/ui/core Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -22,4 +22,37 @@ def render(*args)
2222 end
2323 end
2424
25+ # Matestack allows implicit rendering. When an `index` or `show` action is requested, which is not
26+ # defined, then the matestack page is inferred from the controller name. The index action will
27+ # look for a `Page` with a plural name, the show action will look for a `Page` with a singular
28+ # name.
29+ #
30+ # class Clients::BookingsController < ApplicationController
31+ # def index
32+ # @bookings = Booking.all
33+ # end
34+ #
35+ # def show
36+ # @booking = Booking.find params[:id]
37+ # end
38+ # end
39+ #
40+ # In this example, `clients/bookings#index` will render `Pages::Clients::Bookings`,
41+ # `clients/bookings#show` will render `Pages::Clients::Booking`.
42+ #
43+ def default_render ( *args )
44+ matestack_class_name_parts = "pages/#{ controller_path } " . split ( "/" ) . collect { |str | str . camelcase }
45+ matestack_class_name_parts [ -1 ] = matestack_class_name_parts [ -1 ] . singularize if action_name == "show"
46+ matestack_class_name = matestack_class_name_parts . join ( "::" )
47+ begin
48+ matestack_class = matestack_class_name . constantize
49+ rescue NameError
50+ end
51+ if matestack_class
52+ render matestack : matestack_class
53+ else
54+ super
55+ end
56+ end
57+
2558end
You can’t perform that action at this time.
0 commit comments