Commit 9d4e4550 by liyijie

feat: 优化simple_controller views,支持不带相关路径

parent 573d51d5
json.partial! "<%= view_path %>/simple", <%= resource_singular %>: <%= resource_singular %>
json.partial! "simple", <%= resource_singular %>: <%= resource_singular %>
json.partial! "<%= view_path %>/single", <%= resource_singular %>: <%= resource_singular %>
json.partial! "single", <%= resource_singular %>: <%= resource_singular %>
......@@ -3,4 +3,4 @@ json.total_pages @<%= resource_plural %>.total_pages
json.total_count @<%= resource_plural %>.count
json.statistics @statistics if @statistics.present?
json.records @<%= resource_plural %>, partial: '<%= view_path %>/simple', as: :<%= resource_singular %>
json.records @<%= resource_plural %>, partial: 'simple', as: :<%= resource_singular %>
json.partial! "<%= view_path %>/detail", <%= resource_singular %>: @<%= resource_singular %>
json.partial! "detail", <%= resource_singular %>: @<%= resource_singular %>
......@@ -103,6 +103,11 @@ class SimpleController::BaseController < ::InheritedResources::Base
@view_path
end
# 查找template的时候,能够查找到
def self.local_prefixes
@view_path.present? ? super.unshift(@view_path) : super
end
def defaults(options)
view_path = options.delete(:view_path)
@ransack_off = options.delete(:ransack_off)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment