Reputation: 10360
In my Rails 4.2 app with postgres, the field ui_layout
is converted into json
in the db table (psql supports json data type). The ui_layout
used to be a text
field. After converting ui_layout
to json
in db table, the rendering of the input form new
returns an error as below:
ActionView::Template::Error (No input found for json):
48: <%= f.input :footer, :label => ('Footer') %>
49: <%= f.input :time_periods, :label => ('Time Periods') %>
50: <%= f.input :max_time_period, :label => ('max Time Period') %>
51: <%= f.input :ui_layout, :label => ('UI Layout (json)'), :input_html => {:rows => 2} %>
52:
53:
54: <div class="btn-toolbar" >
simple_form (3.1.1) lib/simple_form/form_builder.rb:574:in `find_mapping'
simple_form (3.1.1) lib/simple_form/form_builder.rb:503:in `find_input'
simple_form (3.1.1) lib/simple_form/form_builder.rb:113:in `input'
/home/ubuntu/.rvm/gems/ruby-2.1.2/bundler/gems/onboard_data_uploadx-f2c20c94f7d6/app/views/onboard_data_uploadx/dashboard_details/_form_new.html.erb:51:in `block in __home_ubuntu__rvm_gems_ruby_______bundler_gems_onboard_data_uploadx_f_c__c__f_d__app_views_onboard_data_uploadx_dashboard_details__form_new_html_erb__2939072899287253628_79696400'
actionview (4.2.0) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionview (4.2.0) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
On the new
input form, the ui_layout
is treated as text
field. What's the right way to enter to a json
field? Do I need to take a text input and convert it into json
in controller?
Upvotes: 0
Views: 220
Reputation: 33542
ActionView::Template::Error (No input found for json)
By natively, simple_form
doesn't support JSON datatype. However you can overwrite the input type which should resolve the problem
<%= f.input :ui_layout, as: :text, :label => ('UI Layout (json)'), :input_html => {:rows => 2} %>
Upvotes: 1