Skip to content

Commit 3c5aeb7

Browse files
author
Lee Richmond
committed
Handle text type in generator
1 parent a726069 commit 3c5aeb7

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/generators/jsonapi/resource_generator.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ def generate_spec_payload
9090
def generate_strong_resource
9191
code = " strong_resource :#{file_name} do\n"
9292
attributes.each do |a|
93-
code << " attribute :#{a.name}, :#{a.type}\n"
93+
type = a.type
94+
type = 'string' if type == 'text'
95+
code << " attribute :#{a.name}, :#{type}\n"
9496
end
9597
code << " end\n"
9698

lib/generators/jsonapi/templates/payload.rb.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
JsonapiSpecHelpers::Payload.register(:<%= file_name %>) do
3333
<%- attributes.each do |a| -%>
3434
<%- type = a.type == :boolean ? [TrueClass, FalseClass] : a.type.to_s.classify -%>
35+
<%- type = String if a.type == :text -%>
3536
key(:<%= a.name %>, <%= type %>)
3637
<%- end -%>
3738
end

0 commit comments

Comments
 (0)