ruby-on-rails – Activeadmin和Paperclip:ArgumentError
发布时间:2020-12-17 03:32:05 所属栏目:百科 来源:网络整理
导读:我使用Activeadmin,paperclip和Rails 4. 当我想创建一个包含多个图像的新文章时,我有这个错误: ArgumentError in Admin::Articles#newwrong number of arguments (1 for 0) 当我尝试只有一个图像时,我有同样的错误. ActiveAdmin:article.rb ActiveAdmin.re
我使用Activeadmin,paperclip和Rails 4.
当我想创建一个包含多个图像的新文章时,我有这个错误: ArgumentError in Admin::Articles#new wrong number of arguments (1 for 0) 当我尝试只有一个图像时,我有同样的错误. ActiveAdmin:article.rb ActiveAdmin.register Article do controller do def permitted_params params.permit article: [:title,:images_attributes => [:picture,:id,:_destroy]] end end form do |f| f.inputs "Project Details" do f.input :title f.has_many :images do |p| p.inputs do p.input :_destroy,:as => :boolean,:label => "Destroy?" unless p.object.new_record? p.input :picture,:as => :file,:hint => p.object.new_record? ? "" : f.template.image_tag(p.object.picture.url(:thumb)) end end end f.actions end end 型号:article.rb class Article < ActiveRecord::Base has_many :images,:dependent => :destroy accepts_nested_attributes_for :images,:allow_destroy => true end 型号:image.rb class Image < ActiveRecord::Base belongs_to :article has_attached_file :picture,:styles => { :large => "960x640>",:medium => "300x300>",:thumb => "150x150>" },:default_url => "/images/:style/missing.png" end 移民 : class CreateImages < ActiveRecord::Migration def change create_table :images do |t| t.belongs_to :article t.attachment :picture t.timestamps end end end 完整跟踪我的错误: paperclip (4.1.1) lib/paperclip/has_attached_file.rb:83:in `block in add_required_validations' formtastic (2.3.0.rc2) lib/formtastic/inputs/base/validations.rb:39:in `call' formtastic (2.3.0.rc2) lib/formtastic/inputs/base/validations.rb:39:in `validator_relevant?' formtastic (2.3.0.rc2) lib/formtastic/inputs/base/validations.rb:27:in `block in validations' formtastic (2.3.0.rc2) lib/formtastic/inputs/base/validations.rb:26:in `select' formtastic (2.3.0.rc2) lib/formtastic/inputs/base/validations.rb:26:in `validations' formtastic (2.3.0.rc2) lib/formtastic/inputs/base/validations.rb:129:in `validations?' formtastic (2.3.0.rc2) lib/formtastic/inputs/base/validations.rb:136:in `required?' formtastic (2.3.0.rc2) lib/formtastic/inputs/base/labelling.rb:25:in `requirement_text_or_proc' formtastic (2.3.0.rc2) lib/formtastic/inputs/base/labelling.rb:29:in `requirement_text' formtastic (2.3.0.rc2) lib/formtastic/inputs/base/labelling.rb:20:in `label_text' formtastic (2.3.0.rc2) lib/formtastic/inputs/base/labelling.rb:9:in `label_html' formtastic (2.3.0.rc2) lib/formtastic/inputs/file_input.rb:36:in `block in to_html' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture' formtastic (2.3.0.rc2) lib/formtastic/inputs/base/wrapping.rb:11:in `input_wrapping' formtastic (2.3.0.rc2) lib/formtastic/inputs/file_input.rb:35:in `to_html' formtastic (2.3.0.rc2) lib/formtastic/helpers/input_helper.rb:241:in `input' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:26:in `block in input' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:151:in `with_new_form_buffer' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:26:in `input' app/admin/article.rb:16:in `block (5 levels) in <top (required)>' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:143:in `block in field_set_and_list_wrapping' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture' formtastic (2.3.0.rc2) lib/formtastic/helpers/fieldset_wrapper.rb:32:in `field_set_and_list_wrapping' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:142:in `field_set_and_list_wrapping' formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:292:in `inputs' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:20:in `block in inputs' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:151:in `with_new_form_buffer' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:20:in `inputs' app/admin/article.rb:14:in `block (4 levels) in <top (required)>' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:61:in `call' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:61:in `block in has_many' formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:375:in `call' formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:375:in `block (2 levels) in inputs_for_nested_attributes' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:143:in `block in field_set_and_list_wrapping' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture' formtastic (2.3.0.rc2) lib/formtastic/helpers/fieldset_wrapper.rb:32:in `field_set_and_list_wrapping' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:142:in `field_set_and_list_wrapping' formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:292:in `inputs' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:20:in `block in inputs' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:151:in `with_new_form_buffer' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:20:in `inputs' formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:373:in `block in inputs_for_nested_attributes' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture' actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1864:in `block in fields_for_nested_model' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture' actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:699:in `fields_for' actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1863:in `fields_for_nested_model' actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1849:in `block in fields_for_with_nested_attributes' actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1847:in `each' actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1847:in `fields_for_with_nested_attributes' actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1521:in `fields_for' formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:391:in `inputs_for_nested_attributes' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:176:in `block in js_for_has_many' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:151:in `with_new_form_buffer' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:176:in `js_for_has_many' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:99:in `block in has_many' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:160:in `block in without_wrapper' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:151:in `with_new_form_buffer' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:160:in `without_wrapper' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:90:in `has_many' app/admin/article.rb:13:in `block (3 levels) in <top (required)>' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:143:in `block in field_set_and_list_wrapping' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture' formtastic (2.3.0.rc2) lib/formtastic/helpers/fieldset_wrapper.rb:32:in `field_set_and_list_wrapping' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:142:in `field_set_and_list_wrapping' formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:292:in `inputs' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:20:in `block in inputs' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:151:in `with_new_form_buffer' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:20:in `inputs' app/admin/article.rb:10:in `block (2 levels) in <top (required)>' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/form.rb:23:in `instance_exec' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/form.rb:23:in `block in main_content' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture' actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:435:in `form_for' formtastic (2.3.0.rc2) lib/formtastic/helpers/form_helper.rb:167:in `block in semantic_form_for' formtastic (2.3.0.rc2) lib/formtastic/helpers/form_helper.rb:190:in `with_custom_field_error_proc' formtastic (2.3.0.rc2) lib/formtastic/helpers/form_helper.rb:166:in `semantic_form_for' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/view_helpers/form_helper.rb:9:in `active_admin_form_for' arbre (1.0.1) lib/arbre/element.rb:175:in `method_missing' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/form.rb:22:in `main_content' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:83:in `block (2 levels) in build_main_content_wrapper' arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag' arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element' arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element' arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag' arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag' arbre (1.0.1) lib/arbre/element/builder_methods.rb:14:in `div' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:82:in `block in build_main_content_wrapper' arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag' arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element' arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element' arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag' arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag' arbre (1.0.1) lib/arbre/element/builder_methods.rb:14:in `div' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:81:in `build_main_content_wrapper' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:65:in `block in build_page_content' arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag' arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element' arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element' arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag' arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag' arbre (1.0.1) lib/arbre/element/builder_methods.rb:14:in `div' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:64:in `build_page_content' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:47:in `block (2 levels) in build_page' arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag' arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element' arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element' arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag' arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag' arbre (1.0.1) lib/arbre/element/builder_methods.rb:14:in `div' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:44:in `block in build_page' arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element' arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:43:in `build_page' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:10:in `build' arbre (1.0.1) lib/arbre/element/builder_methods.rb:30:in `block in build_tag' arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element' arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag' arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/app/views/active_admin/resource/new.html.arb:1:in `block in __home_bibou__rvm_gems_ruby_______p____bundler_gems_active_admin___de_f__ae_d_app_views_active_admin_resource_new_html_arb__2699006568721876069_69819426589980' arbre (1.0.1) lib/arbre/context.rb:45:in `instance_eval' arbre (1.0.1) lib/arbre/context.rb:45:in `initialize' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/app/views/active_admin/resource/new.html.arb:1:in `new' /home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/app/views/active_admin/resource/new.html.arb:1:in `__home_bibou__rvm_gems_ruby_______p____bundler_gems_active_admin___de_f__ae_d_app_views_active_admin_resource_new_html_arb__2699006568721876069_69819426589980' actionpack (4.0.2) lib/action_view/template.rb:143:in `block in render' activesupport (4.0.2) lib/active_support/notifications.rb:161:in `instrument' actionpack (4.0.2) lib/action_view/template.rb:141:in `render' actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:49:in `block (2 levels) in render_template' actionpack (4.0.2) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument' activesupport (4.0.2) lib/active_support/notifications.rb:159:in `block in instrument' activesupport (4.0.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (4.0.2) lib/active_support/notifications.rb:159:in `instrument' actionpack (4.0.2) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument' actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:48:in `block in render_template' actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:56:in `render_with_layout' actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:47:in `render_template' actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:17:in `render' actionpack (4.0.2) lib/action_view/renderer/renderer.rb:42:in `render_template' actionpack (4.0.2) lib/action_view/renderer/renderer.rb:23:in `render' actionpack (4.0.2) lib/abstract_controller/rendering.rb:127:in `_render_template' actionpack (4.0.2) lib/action_controller/metal/streaming.rb:219:in `_render_template' actionpack (4.0.2) lib/abstract_controller/rendering.rb:120:in `render_to_body' actionpack (4.0.2) lib/action_controller/metal/rendering.rb:33:in `render_to_body' actionpack (4.0.2) lib/action_controller/metal/renderers.rb:26:in `render_to_body' actionpack (4.0.2) lib/abstract_controller/rendering.rb:97:in `render' actionpack (4.0.2) lib/action_controller/metal/rendering.rb:16:in `render' actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render' activesupport (4.0.2) lib/active_support/core_ext/benchmark.rb:12:in `block in ms' /home/bibou/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/benchmark.rb:296:in `realtime' activesupport (4.0.2) lib/active_support/core_ext/benchmark.rb:12:in `ms' actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:41:in `block in render' actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime' activerecord (4.0.2) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime' actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:40:in `render' actionpack (4.0.2) lib/action_controller/metal/implicit_render.rb:10:in `default_render' actionpack (4.0.2) lib/action_controller/metal/responder.rb:233:in `default_render' actionpack (4.0.2) lib/action_controller/metal/responder.rb:161:in `to_html' responders (1.0.0) lib/responders/flash_responder.rb:104:in `to_html' actionpack (4.0.2) lib/action_controller/metal/responder.rb:154:in `respond' actionpack (4.0.2) lib/action_controller/metal/responder.rb:147:in `call' actionpack (4.0.2) lib/action_controller/metal/mime_responds.rb:330:in `respond_with' inherited_resources (1.4.1) lib/inherited_resources/actions.rb:19:in `new' actionpack (4.0.2) lib/action_controller/metal/implicit_render.rb:4:in `send_action' actionpack (4.0.2) lib/abstract_controller/base.rb:189:in `process_action' actionpack (4.0.2) lib/action_controller/metal/rendering.rb:10:in `process_action' actionpack (4.0.2) lib/abstract_controller/callbacks.rb:18:in `block in process_action' activesupport (4.0.2) lib/active_support/callbacks.rb:433:in `_run__2406119207582674973__process_action__callbacks' activesupport (4.0.2) lib/active_support/callbacks.rb:80:in `run_callbacks' actionpack (4.0.2) lib/abstract_controller/callbacks.rb:17:in `process_action' actionpack (4.0.2) lib/action_controller/metal/rescue.rb:29:in `process_action' actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action' activesupport (4.0.2) lib/active_support/notifications.rb:159:in `block in instrument' activesupport (4.0.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (4.0.2) lib/active_support/notifications.rb:159:in `instrument' actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:30:in `process_action' actionpack (4.0.2) lib/action_controller/metal/params_wrapper.rb:245:in `process_action' activerecord (4.0.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action' actionpack (4.0.2) lib/abstract_controller/base.rb:136:in `process' actionpack (4.0.2) lib/abstract_controller/rendering.rb:44:in `process' actionpack (4.0.2) lib/action_controller/metal.rb:195:in `dispatch' actionpack (4.0.2) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch' actionpack (4.0.2) lib/action_controller/metal.rb:231:in `block in action' actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:80:in `call' actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:80:in `dispatch' actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:48:in `call' actionpack (4.0.2) lib/action_dispatch/journey/router.rb:71:in `block in call' actionpack (4.0.2) lib/action_dispatch/journey/router.rb:59:in `each' actionpack (4.0.2) lib/action_dispatch/journey/router.rb:59:in `call' actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:680:in `call' warden (1.2.3) lib/warden/manager.rb:35:in `block in call' warden (1.2.3) lib/warden/manager.rb:34:in `catch' warden (1.2.3) lib/warden/manager.rb:34:in `call' rack (1.5.2) lib/rack/etag.rb:23:in `call' rack (1.5.2) lib/rack/conditionalget.rb:25:in `call' rack (1.5.2) lib/rack/head.rb:11:in `call' actionpack (4.0.2) lib/action_dispatch/middleware/params_parser.rb:27:in `call' actionpack (4.0.2) lib/action_dispatch/middleware/flash.rb:241:in `call' rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context' rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call' actionpack (4.0.2) lib/action_dispatch/middleware/cookies.rb:486:in `call' activerecord (4.0.2) lib/active_record/query_cache.rb:36:in `call' activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call' activerecord (4.0.2) lib/active_record/migration.rb:369:in `call' actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' activesupport (4.0.2) lib/active_support/callbacks.rb:373:in `_run__1775309793310121907__call__callbacks' activesupport (4.0.2) lib/active_support/callbacks.rb:80:in `run_callbacks' actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call' actionpack (4.0.2) lib/action_dispatch/middleware/reloader.rb:64:in `call' actionpack (4.0.2) lib/action_dispatch/middleware/remote_ip.rb:76:in `call' actionpack (4.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' actionpack (4.0.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' railties (4.0.2) lib/rails/rack/logger.rb:38:in `call_app' railties (4.0.2) lib/rails/rack/logger.rb:20:in `block in call' activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `block in tagged' activesupport (4.0.2) lib/active_support/tagged_logging.rb:25:in `tagged' activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `tagged' railties (4.0.2) lib/rails/rack/logger.rb:20:in `call' actionpack (4.0.2) lib/action_dispatch/middleware/request_id.rb:21:in `call' rack (1.5.2) lib/rack/methodoverride.rb:21:in `call' rack (1.5.2) lib/rack/runtime.rb:17:in `call' activesupport (4.0.2) lib/active_support/cache/strategy/local_cache.rb:83:in `call' rack (1.5.2) lib/rack/lock.rb:17:in `call' actionpack (4.0.2) lib/action_dispatch/middleware/static.rb:64:in `call' rack (1.5.2) lib/rack/sendfile.rb:112:in `call' railties (4.0.2) lib/rails/engine.rb:511:in `call' railties (4.0.2) lib/rails/application.rb:97:in `call' rack (1.5.2) lib/rack/lock.rb:17:in `call' rack (1.5.2) lib/rack/content_length.rb:14:in `call' rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service' /home/bibou/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' /home/bibou/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' /home/bibou/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread' 谢谢您的帮助 编辑: 我将这个宝石用于我的项目: gem 'devise' gem 'cancan' gem 'activeadmin',github: 'gregbell/active_admin' gem 'annotate' gem 'ckeditor' gem "paperclip","~> 4.1" 我的操作系统是Ubuntu,我使用ImageMagick-6.8.8-7. 当我运行哪个转换 development.rb PaperclipActiveadmin::Application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations config.active_record.migration_error = :page_load # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true # configure paperclip Paperclip.options[:command_path] = "/usr/local/bin/" end 方案: 在我的输入中添加require:false: p.input :picture,:hint => p.object.new_record? ? "" : f.template.image_tag(p.object.picture.url(:thumb)),required: false 在我的image.rb中添加validates_attachment_content_type: validates_attachment_content_type :picture,:content_type => ["image/jpg","image/jpeg","image/png"] 感谢Philip Hallstrom的帮助和解决方案 解决方法
根据
https://github.com/justinfrench/formtastic/issues/999,临时解决方案是在输入中添加require:false.像这样:
f.input :image,required: false 刚尝试过,它对我有用. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- React + Typescript + Webpack 开发环境配置
- ruby-on-rails – Heroku是否保护个人网站免受DoS / DDoS攻
- Parsing arithmetic expressions - Bison and Flex
- oracle – 使用连接字符串从命令行连接到sql plus
- 在Sqlite中通过Replace来实现插入和更新
- TabHeader不能点击的问题
- The Swift Programming Language学习笔记(一)——初见Swi
- 一文读懂DDD
- ios – 为什么我找不到XCTest / XCTest.h?
- 如何用jest模拟react-native模块(不是第三方模块)