Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
simple_controller
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
simple_controller
Commits
9d4e4550
Commit
9d4e4550
authored
Oct 11, 2021
by
liyijie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 优化simple_controller views,支持不带相关路径
parent
573d51d5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
4 deletions
+9
-4
_detail.json.jbuilder
...s/simple_controller/templates/views/_detail.json.jbuilder
+1
-1
_simple.json.jbuilder
...s/simple_controller/templates/views/_simple.json.jbuilder
+1
-1
index.json.jbuilder
...ors/simple_controller/templates/views/index.json.jbuilder
+1
-1
show.json.jbuilder
...tors/simple_controller/templates/views/show.json.jbuilder
+1
-1
base_controller.rb
lib/simple_controller/base_controller.rb
+5
-0
No files found.
lib/generators/simple_controller/templates/views/_detail.json.jbuilder
View file @
9d4e4550
json.partial! "
<%= view_path %>/
simple", <%= resource_singular %>: <%= resource_singular %>
json.partial! "simple", <%= resource_singular %>: <%= resource_singular %>
lib/generators/simple_controller/templates/views/_simple.json.jbuilder
View file @
9d4e4550
json.partial! "
<%= view_path %>/
single", <%= resource_singular %>: <%= resource_singular %>
json.partial! "single", <%= resource_singular %>: <%= resource_singular %>
lib/generators/simple_controller/templates/views/index.json.jbuilder
View file @
9d4e4550
...
...
@@ -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 %>
lib/generators/simple_controller/templates/views/show.json.jbuilder
View file @
9d4e4550
json.partial! "
<%= view_path %>/
detail", <%= resource_singular %>: @<%= resource_singular %>
json.partial! "detail", <%= resource_singular %>: @<%= resource_singular %>
lib/simple_controller/base_controller.rb
View file @
9d4e4550
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment