Merge pull request #3909 from apanzerj/apanzerj/fixupRails5Server

WIP: Fixup rails5 server
This commit is contained in:
wing328
2016-10-05 01:16:47 +08:00
committed by GitHub
8 changed files with 12 additions and 12 deletions

View File

@@ -281,8 +281,8 @@ public class Rails5ServerCodegen extends DefaultCodegen implements CodegenConfig
// replace - with _ e.g. created-at => created_at
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
// e.g. PhoneNumberApi.rb => phone_number_api.rb
return underscore(name) + "_controllers";
// e.g. DefaultController => defaults_controller.rb
return underscore(name) + "s_controller";
}
@Override

View File

@@ -4,7 +4,7 @@
class InitTables < ActiveRecord::Migration
def change{{#models}}{{#model}}
create_table :{{classFilename}}, id: false do |t|{{#vars}}{{#isContainer}}
create_table "{{classFilename}}".pluralize.to_sym, id: false do |t|{{#vars}}{{#isContainer}}
t.string :{{name}}{{/isContainer}}{{^isContainer}}
t.{{datatype}} :{{{name}}}{{/isContainer}}{{/vars}}

View File

@@ -5,7 +5,7 @@
{{#models}}{{#model}}
class {{classname}} < ApplicationRecord
{{#requiredVars}}
validate_presence_of :{{name}}
validates_presence_of :{{name}}
{{/requiredVars}}{{#vars}}{{#isListContainer}}
serialize :{{name}}, Array{{/isListContainer}}{{#isMapContainer}}
serialize :{{name}}, Hash{{/isMapContainer}}{{/vars}}

View File

@@ -23,8 +23,8 @@ limitations under the License.
class Pet < ApplicationRecord
validate_presence_of :name
validate_presence_of :photo_urls
validates_presence_of :name
validates_presence_of :photo_urls
serialize :photo_urls, Array
serialize :tags, Array

View File

@@ -23,7 +23,7 @@ limitations under the License.
class InitTables < ActiveRecord::Migration
def change
create_table :api_response, id: false do |t|
create_table "api_response".pluralize.to_sym, id: false do |t|
t.integer :code
t.string :type
t.string :message
@@ -31,14 +31,14 @@ class InitTables < ActiveRecord::Migration
t.timestamps
end
create_table :category, id: false do |t|
create_table "category".pluralize.to_sym, id: false do |t|
t.integer :id
t.string :name
t.timestamps
end
create_table :order, id: false do |t|
create_table "order".pluralize.to_sym, id: false do |t|
t.integer :id
t.integer :pet_id
t.integer :quantity
@@ -49,7 +49,7 @@ class InitTables < ActiveRecord::Migration
t.timestamps
end
create_table :pet, id: false do |t|
create_table "pet".pluralize.to_sym, id: false do |t|
t.integer :id
t.string :category
t.string :name
@@ -60,14 +60,14 @@ class InitTables < ActiveRecord::Migration
t.timestamps
end
create_table :tag, id: false do |t|
create_table "tag".pluralize.to_sym, id: false do |t|
t.integer :id
t.string :name
t.timestamps
end
create_table :user, id: false do |t|
create_table "user".pluralize.to_sym, id: false do |t|
t.integer :id
t.string :username
t.string :first_name