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
5362256e
Commit
5362256e
authored
Dec 31, 2017
by
liyijie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add resource not exist protection
parent
bc05441b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
0 deletions
+3
-0
simple_controller_generator.rb
...nerators/simple_controller/simple_controller_generator.rb
+1
-0
spec.rb.tt
lib/generators/simple_controller/templates/specs/spec.rb.tt
+2
-0
No files found.
lib/generators/simple_controller/simple_controller_generator.rb
View file @
5362256e
...
...
@@ -10,6 +10,7 @@ class SimpleControllerGenerator < Rails::Generators::NamedBase
def
setup
@routes
=
RSpec
::
Rails
::
Swagger
::
RouteParser
.
new
(
controller_path
.
sub
(
/^\//
,
''
)).
routes
p
"Warning!! Resource is not exist, CHECK & regenerate after you have configurate the model and routes already"
if
resource_class
&
.
columns_hash
.
blank?
end
def
create_controller_files
...
...
lib/generators/simple_controller/templates/specs/spec.rb.tt
View file @
5362256e
...
...
@@ -4,9 +4,11 @@ require 'swagger_helper'
type: :object, properties: {
<%= singular_name %>: {
type: :object, properties: {
<% if resource_class&.columns_hash.present? -%>
<% resource_class.columns_hash.except('id', 'created_at', 'updated_at').values.each do |column| -%>
<%= column.name %>: { type: :<%= column.type %>, description: '' },
<% end -%>
<% end -%>
}
}
}
...
...
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