当模型与视图交互时,Rails抛出异常

时间:2015-07-20 23:44:22

标签: ruby-on-rails

以下是我的控制器代码:

 render json: {}, status: :bad_request and return if params[:service].nil?
 service = Service.find_by_name(params[:service])
 certification = Certification.find_by_build(params[:version])
 join_table = service.certifications.select('id','build','is_certified').where(:build=>certification.build,:service_id=>service.id)
 render json: join_table.to_json, status: :ok
Unexpected error while processing request: undefined method `to_i' for #<Array:0x007fec563f7bf0>
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/rack-1.5.3/lib/rack/content_length.rb:17:in `call'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/thin-1.6.3/lib/thin/connection.rb:86:in `block in pre_process'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/thin-1.6.3/lib/thin/connection.rb:84:in `catch'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/thin-1.6.3/lib/thin/connection.rb:84:in `pre_process'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/thin-1.6.3/lib/thin/connection.rb:53:in `process'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/thin-1.6.3/lib/thin/connection.rb:39:in `receive_data'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/eventmachine-1.0.7/lib/eventmachine.rb:187:in `run_machine'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/eventmachine-1.0.7/lib/eventmachine.rb:187:in `run'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/thin-1.6.3/lib/thin/backends/base.rb:73:in `start'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/thin-1.6.3/lib/thin/server.rb:162:in `start'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/rack-1.5.3/lib/rack/handler/thin.rb:16:in `run'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/rack-1.5.3/lib/rack/server.rb:264:in `start'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/commands/server.rb:69:in `start'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:81:in `block in server'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:76:in `tap'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:76:in `server'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    /Users/pnagashr/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/commands.rb:17:in `<top (required)>'
    bin/rails:8:in `require'
    bin/rails:8:in `<main>'

0 个答案:

没有答案