2

私は最初のRoRプロジェクトに取り組んでおり、ペーパークリップの宝石を使おうとしていますが、理解できないエラーが発生しています。

引数の数が間違っています(0の場合は1)
app / controllers / events_controller.rb:43:in `create'
パラメーター:

{"utf8"=>"✓",
 "authenticity_token"=>"OBYHA0M+TA93sNF3uqrJ/zvnnEyWJUREn4NcOl0ExfA=",
 "event"=>{"title"=>"",
 "image"=>#<ActionDispatch::Http::UploadedFile:0x007f803802b1f0 @original_filename="icon.png",
 @content_type="image/png",
 @headers="Content-Disposition: form-data; name=\"event[image]\"; filename=\"icon.png\"\r\nContent-Type: image/png\r\n",
 @tempfile=#<File:/tmp/RackMultipart20130217-21480-1molvwa>>,
 "description"=>"",
 "date"=>"",
 "time"=>""},
 "commit"=>"Create Event"}

createメソッドのevents_controller.rbで渡される引数が多すぎることを理解しています。ただし、PaperclipのGithubのQuickStartの手順に従ったため、このエラーが発生する理由がわかりません。

これがevents_controller.rbの私のコードです

def create
    @event = Event.create( params[:event] )
 end

デバッグのために、行をEvent.create(params [])に変更しようとしました。その時点で、エラーは間違った数の引数(1の場合は1)から間違った数の引数(0の場合は1)に変わりました。

これがevent.rbの私のコードです

class Event < ActiveRecord::Base
    attr_accessible :date, :description, :time, :title, :image
    has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" }
end

すべてに対して正しいバージョンを実行していることを確認しました。私はPaperclip3.4.0、Rails 3.2.12、Ruby 1.9.3、およびImageMagick6.8.3-1を持っています。Ubuntu12.04LTSを使用しています。

私はかなりの数の同様の問題を見てきましたが、ほとんどは数年前に発生したようで、その後のペーパークリップのアップデートで解決されました。同様の投稿で見つけた解決策はどれもうまくいきませんでした。残念ながら、Railsの経験はまだ十分で、何が起こっているのかを知ることはできません。私はおそらく完全な初心者の間違いを犯していることを認識しています。その場合、私は謝罪しますが、それでも私を正しい軌道に乗せるための助けを本当に感謝します。

追加のコードや情報がデバッグに役立つかどうか教えてください。

御時間ありがとうございます!

アプリケーショントレース:

コカイン(0.3.2)lib / cocaine / command_line.rb:63:in run' /home/user/.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/helpers.rb:31:in run'/home/user /.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/geometry_detector_factory .rb:18:in block in geometry_string' activesupport (3.2.12) lib/active_support/core_ext/kernel/reporting.rb:43:insilence_stream'/home/user/.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/ geometry_detector_factory.rb:17:in geometry_string' /home/user/.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/geometry_detector_factory.rb:9:in make'/ home / user /.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/geometry.rb:26:ininitialize'/home/user/.rvm/gems/ruby-1.9 from_file' /home/user/.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/thumbnail.rb:35:in 。 3-p385 / bundler / gems / paperclip-dcd2774e7913 / lib / paperclip / Processor.rb:33:in new' /home/user/.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/processor.rb:33:in make'/home/user /.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913 /lib/paperclip/attachment.rb:431:in block in post_process_style' /home/user/.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/attachment.rb:430:in 各'/home/user/.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/attachment.rb:430:inpost_process_style inject' /home/user/.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/attachment.rb:430:in ' /home/user/.rvm/gems /ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/attachment.rb:423:in block in post_process_styles' /home/user/.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/attachment.rb:422:in each'/home/user/ .rvm/gems/ruby-1.9.3-p385/bundler/ gems / paperclip-dcd2774e7913 / lib / paperclip / attachment.rb:422:in post_process_styles' /home/user/.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/attachment.rb:415:in ブロック(2レベル)in post_process'activesupport(3.2.12)lib / active_support / callbacks.rb:403:in _run__3384881169595487878__image_post_process__96086910066492375__callbacks' activesupport (3.2.12) lib/active_support/callbacks.rb:405:in __run_callback' activesupport(3.2.12) lib / active_support / callbacks.rb:385:in _run_image_post_process_callbacks' activesupport (3.2.12) lib/active_support/callbacks.rb:81:inrun_callbacks'/home/user /.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/callbacks.rb:26:in run_paperclip_callbacks' /home/user/.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/attachment.rb:414:in post_processのactivesupport(3.2.12)lib / active_support / callbacks.rb:403のブロック: の_run__3384881169595487878__post_process__96086910066492375__callbacks' activesupport (3.2.12) lib/active_support/callbacks.rb:405:in __run_callback'activesupport(3.2.12)lib / active_support / callbacks.rb:385:in _run_post_process_callbacks' activesupport (3.2.12) lib/active_support/callbacks.rb:81:in run_callbacks' /home/user/.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip /callbacks.rb:26:in run_paperclip_callbacks' /home/user/.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/attachment.rb:413:in post_process'/home/user/.rvm/gems/ ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip/attachment.rb:108: assign' /home/user/.rvm/gems/ruby-1.9.3-p385/bundler/gems/paperclip-dcd2774e7913/lib/paperclip.rb:200:inin block in has_attached_file 'activerecord(3.2.12)lib / active_record / attribute_assignment.rb:85:in block in assign_attributes' activerecord (3.2.12) lib/active_record/attribute_assignment.rb:78:ineach' activerecord(3.2.12)lib / active_record / attribute_assignment.rb:78:in assign_attributes' activerecord (3.2.12) lib/active_record/base.rb:497:ininitialize'activerecord(3.2.12)lib / active_record / persistence .rb:44:in new' activerecord (3.2.12) lib/active_record/persistence.rb:44:increate'app / controllers / events_controller.rb:43:in create' actionpack (3.2.12) lib/action_controller/metal/implicit_render.rb:4:in send_action' actionpack(3.2.12)lib / abstract_controller / base.rb:167:inprocess_action' actionpack (3.2.12) lib/action_controller/metal/rendering.rb:10:in process_action'actionpack(3.2.12)lib / abstract_controller / callbacks.rb:18:in block in process_action' activesupport (3.2.12) lib/active_support/callbacks.rb:414:in run _3332570171411252513__process_action_ 3320642634939127128 _callbacks' activesupport(3.2.12)lib / active_support / callbacks.rb:405:in __run_callback' activesupport (3.2.12) lib/active_support/callbacks.rb:385:in_run_process_action_callbacks'activesupport(3.2.12) /active_support/callbacks.rb:81:in run_callbacks' actionpack (3.2.12) lib/abstract_controller/callbacks.rb:17:inprocess_action'actionpack(3.2.12)lib / action_controller / metal / rescue.rb:29:in process_action' actionpack (3.2.12) lib/action_controller/metal/instrumentation.rb:30:inblock in process_action' activesupport(3.2.12)lib / active_support / notification.rb:123 :block in instrument' activesupport (3.2.12) lib/active_support/notifications/instrumenter.rb:20:inininstrument'activesupport(3.2.12)lib / active_support / notification.rb:123:in instrument' actionpack (3.2.12) lib/action_controller/metal/instrumentation.rb:29:inprocess_action' actionpack(3.2.12)lib / action_controller / metal / params_wrapper.rb:207:inprocess_action' activerecord (3.2.12) lib/active_record/railties/controller_runtime.rb:18:in process_action'actionpack(3.2.12)lib / abstract_controller / base.rb:121:in process' actionpack (3.2.12) lib/abstract_controller/rendering.rb:45:inprocess' actionpack(3.2.12)lib / action_controller / metal.rb:203:in dispatch' actionpack (3.2.12) lib/action_controller/metal/rack_delegation.rb:14:in dispatch'actionpack(3.2.12)lib / action_controller / metal.rb:246:in call'actionpack block in action' actionpack (3.2.12) lib/action_dispatch/routing/route_set.rb:73:in(3.2.12)lib / action_dispatch / routing / route_set.rb:73:in call'journey dispatch' actionpack (3.2.12) lib/action_dispatch/routing/route_set.rb:36:in (1.0.4)lib / journal / router.rb:68:in block in call' journey (1.0.4) lib/journey/router.rb:56:ineach'journey (1.0.4)lib / journal / router.rb:56:in call'actionpack call' actionpack (3.2.12) lib/action_dispatch/routing/route_set.rb:601:in(3.2.12)lib / action_dispatch / Middleware / best_standards_support.rb:17:in call' rack (1.4.5) lib/rack/etag.rb:23:incall' Rack(1.4.5)lib / Rack / conditionalget .rb:35:in call'actionpack call' actionpack (3.2.12) lib/action_dispatch/middleware/head.rb:14:in(3.2.12)lib / action_dispatch / Middleware / params_parser.rb:21:in call' actionpack (3.2.12) lib/action_dispatch/middleware/flash.rb:242:in call' Rack(1.4.5)lib / Rack / session / abstract / id.rb:210:incontext' rack (1.4.5) lib/rack/session/abstract/id.rb:205:incall'actionpack(3.2.12)lib / action_dispatch / middleware / Cookies.rb:341:in call' activerecord (3.2.12) lib/active_record/query_cache.rb:64:incall' activerecord(3.2.12)lib / active_record / connection_adapters / abstract / connection_pool.rb:479:in call' actionpack (3.2.12) lib/action_dispatch/middleware/callbacks.rb:28:inblock in call'activesupport( 3.2.12)lib / active_support / callbacks.rb:405:in _run__1281245379307539657__call__96086910066492375__callbacks' activesupport (3.2.12) lib/active_support/callbacks.rb:405:in __run_callback'activesupport(3.2.12)lib / active_support / callbacks.rb:385:in _run_call_callbacks' activesupport (3.2.12) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack(3.2.12)lib / action_dispatch / Middleware/callbacks。 rb:27:in call' actionpack (3.2.12) lib/action_dispatch/middleware/reloader.rb:65:incall'actionpack(3.2.12)lib / action_dispatch / middleware / remote_ip.rb:31:in call' actionpack (3.2.12) lib/action_dispatch/middleware/debug_exceptions.rb:16:incall' actionpack(3.2.12)lib / action_dispatch / middleware / show_exceptions.rb:56:in call' railties (3.2.12) lib/rails/rack/logger.rb:32:incall_app'railties (3.2.12)lib / rails / Rack / logger.rb:16:inblock in call' activesupport (3.2.12) lib/active_support/tagged_logging.rb:22:inタグ付き'railties(3.2.12)lib / rails / Rack / logger.rb:16:incall' actionpack (3.2.12) lib/action_dispatch/middleware/request_id.rb:22:incall'rack(1.4.5)lib / Rack / methodoverride.rb:21:in call' rack (1.4.5) lib/rack/runtime.rb:17:incall' activesupport(3.2.12)lib / active_support / cache /strategy / local_cache.rb:72:in call'actionpack call' rack (1.4.5) lib/rack/lock.rb:15:in(3.2.12) lib / action_dispatch / Middleware / static.rb:62:in call' railties (3.2.12) lib/rails/engine.rb:479:incall'railties(3.2.12)lib / rails / application.rb:223:in call' rack (1.4.5) lib/rack/content_length.rb:14:incall' railties(3.2.12)lib / rails / rack / log_tailer.rb: 17:in call' rack (1.4.5) lib/rack/handler/webrick.rb:59:inservice'/home/user /.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/webrick/httpserver.rb:138:in service' /home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/webrick/httpserver.rb:94:in run' /home/user/.rvm/ rubies / ruby​​-1.9.3-p385 / lib / ruby​​ / 1.9.1 / webrick / server.rb:191:in `block in start_thread '

4

1 に答える 1

4

間違ったバージョンのコカインを使用しています。実行してから、Railsサーバーの起動にbundle install使用していることを確認してください。bundle exec rails s

def run(interpolations = {})新しいバージョンのコカイン(〜> 0.4.0)のrunメソッドは、古いバージョン(0.3.2)ではなかったオプションの引数( )を取ります。

上記のコメントを参照してください。

于 2013-02-19T20:15:18.260 に答える