Skip to content

Commit 0cd4212

Browse files
committed
implement rendering of custom controller actions
suggested by #303
1 parent 60944a3 commit 0cd4212

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

app/lib/matestack/ui/core/render.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,20 @@ def render(*args)
4040
# In this example, `clients/bookings#index` will render `Pages::Clients::Bookings`,
4141
# `clients/bookings#show` will render `Pages::Clients::Booking`.
4242
#
43+
# Custom action names translate also into page names.
44+
#
45+
# class Clients::BookingsController < ApplicationController
46+
# def step1
47+
# end
48+
# end
49+
#
50+
# In this example, the `clients/bookings#step1` action will render
51+
# `Pages::Clients::Bookings::Step1`.
52+
#
4353
def default_render(*args)
44-
matestack_class_name_parts = "pages/#{controller_path}".split("/").collect { |str| str.camelcase }
54+
matestack_page_path = "pages/#{controller_path}"
55+
matestack_page_path = "#{matestack_page_path}/#{action_name}" unless action_name.in? %w(index show)
56+
matestack_class_name_parts = matestack_page_path.split("/").collect { |str| str.camelcase }
4557
matestack_class_name_parts[-1] = matestack_class_name_parts[-1].singularize if action_name == "show"
4658
matestack_class_name = matestack_class_name_parts.join("::")
4759
begin

0 commit comments

Comments
 (0)