Skip to content

Commit

Permalink
Merge pull request #2891 from quainjn/page_title_config
Browse files Browse the repository at this point in the history
Allow index page_title to be set in controller
  • Loading branch information
seanlinsley committed Jan 24, 2014
2 parents b7e8c7d + eeecdd5 commit f929210
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
11 changes: 11 additions & 0 deletions features/index/page_title.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,14 @@ Feature: Index - Page Title
end
"""
Then I should see the page title "List of posts"

Scenario: Set the title in controller
Given an index configuration of:
"""
ActiveAdmin.register Post do
controller do
before_filter { @page_title = "List of #{resource_class.model_name.plural}" }
end
end
"""
Then I should see the page title "List of posts"
11 changes: 11 additions & 0 deletions features/show/page_title.feature
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,14 @@ Feature: Show - Page Title
ActiveAdmin.register Tag
"""
Then I should see the page title "Tag #"

Scenario: Set the title in controller
Given a show configuration of:
"""
ActiveAdmin.register Post do
controller do
before_filter { @page_title = "List of #{resource_class.model_name.plural}" }
end
end
"""
Then I should see the page title "List of posts"
2 changes: 1 addition & 1 deletion lib/active_admin/views/pages/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def title
when Proc then controller.instance_exec &config[:title]
when String then config[:title]
else
active_admin_config.plural_resource_label
assigns[:page_title] || active_admin_config.plural_resource_label
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/active_admin/views/pages/show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def title
if config[:title]
render_or_call_method_or_proc_on(resource, config[:title])
else
default_title
assigns[:page_title] || default_title
end
end

Expand Down

0 comments on commit f929210

Please sign in to comment.