更新了宝石,现在出现错误:ActionView :: Template :: Error(错误的参数数量(2为1)):

时间:2019-04-11 02:56:50

标签: ruby-on-rails ruby-on-rails-4 upgrade rails-4-upgrade

尝试将项目从Rails 3.2更新到Rails 4.0。更新了一些gem之后,我遇到了一些错误和不赞成使用的内容,例如在运行“ rails s”时使用哈希调用#scope。修复后,“ rails s”有效,但是当我尝试去本地主机测试我的web应用程序时,出现此错误:

<body>
<div class="container">
<p>Select Email templates below</p>

<!-- Mr/Mrs and Customer name field start here -->
  <form id="mainForm" name="mainForm">
    <input type="radio" name="gender" value="Mr. " />Mr.
    <input type="radio" name="gender" value="Mrs. " />Mrs.
    <textarea id="textarea" placeholder="Enter customer name here" oninput="renderYourText()"></textarea>
  </form>
<!-- Mr/Mrs and Customer name field end here -->

<!-- Email template drop down start here -->
<div class="button dropdown"> 
  <select id="colorselector" onchange="renderYourText()">
     <option></option>
     <option value="Cancellation">Cancellation</option>
     <option value="Refund">Refund</option>
  </select>
</div>

<div id="Cancellation" class="colors red"> 


</div>

<div id="Refund" class="colors red"> 

</div>

 </div>

<!-- Email template drop down start here -->

<!-- Text area result box start here -->
<textarea class="form-control" rows="5" id="result" name="text"></textarea>
<!-- Text area result box end here -->

<!-- Jquery and Javascript start here -->
<script>


</script>
<!-- Jquery and Javascript end here -->

</body>

这是“最新更新列表”方法:

    ActionView::Template::Error (wrong number of arguments (2 for 1)):
     5:       %th Activities
     6:       %th.w140
     7:   %tbody
     8:     - (list = latest_updates_list(@filter[:latest_updates_options])).each do |item|
     9:       %tr= latest_updates_item_helper(item)
    10:
    11:     - if list.length == 0
  app/helpers/dashboard_helper.rb:33:in `latest_updates_list'
  app/views/dashboard/_index.html.haml:8:in `_app_views_dashboard__index_html_haml__3401685304950220196_70213556660400'
  app/views/dashboard/index.html.haml:6:in `_app_views_dashboard_index_html_haml___725444960778701440_70213519668520'

这是“ latest_updates_list”中的第33行:

def latest_updates_list(option=nil)
    client_ids = current_user.actual_client_ids

    services = {}
    Service.where(:client_id => client_ids).each{|s| services[s.id] = {:name => s.name, :frequency_name => s.frequency_short_text, :per_hour => s.per_hour?} }

    reports = []
    invoices = []
    tickets = []
    employees = []

    list = []
    case option.to_sym
    when :reports
      reports = Report.for_latest_updates(client_ids) if (user_admin? || user_can_report?)
    when :invoices
      invoices = Invoice.for_latest_updates(client_ids) if (user_admin? || user_can_invoice?)
    when :tickets
      tickets = Ticket.for_latest_updates(client_ids) if (user_admin? || user_can_ticket?)
    when :employees
      employees = Employee.for_latest_updates(current_user.filter_client_id, client_ids) if user_admin?
    else
      reports = Report.for_latest_updates(client_ids) if (user_admin? || user_can_report?)
      invoices = Invoice.for_latest_updates(client_ids) if (user_admin? || user_can_invoice?)
      tickets = Ticket.for_latest_updates(client_ids) if (user_admin? || user_can_ticket?)
      employees = Employee.for_latest_updates(current_user.filter_client_id, client_ids) if user_admin?
    end

    list += reports.collect do |r|
       {
         :date => r.updated_at,
         :entity => 1,
         :status_text => latest_update_report_status_text(r),
         :reports_services_text => latest_updates_reports_services_text(r, r.reports_services),
         :report_id => r.id}
    end unless reports.empty?

    list += invoices.collect do |i|
       {
         :date => i.updated_at,
         :entity => 2,
         :status_text => latest_update_invoice_status_text(i),
         :invoice_reports_services_text => latest_updates_invoice_reports_services_text(services, i.reports),
         :invoice_id => i.id}
    end unless invoices.empty?

    list += tickets.collect do |t|
       {
         :date => latest_update_ticket_date(t),
         :entity => 3,
         :status_text => latest_update_ticket_status_text(t),
         :description => t.description_text,
         :ticket_id => t.id}
    end unless tickets.empty?

    list += employees.collect do |e|
       {
         :date => e.updated_at,
         :entity => 4,
         :description => e.text_for_stream,
         :employee_id => e.employee_id}
    end unless employees.empty?

    sorted_list = list.sort{|a, b| a[:date].to_i <=> b[:date].to_i}
    list = sorted_list.reverse!
    list = list.take(50)
  end

这是我的Gemfile.lock

    Service.where(:client_id => client_ids).each{|s| services[s.id] = {:name => s.name, :frequency_name => s.frequency_short_text, :per_hour => s.per_hour?} }

我认为这一定是一个gem问题,因为它以前一直在工作,并且我没有更改这些文件中的任何内容。

这是我更新的宝石的副本:

GIT
  remote: git://github.com/rails/sass-rails.git
  revision: 8588b7b31d708a91516ae3bda0f57601a860ec28
  branch: 4-0-stable
  specs:
    sass-rails (4.0.5)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.2.2)
      sprockets (~> 2.8, < 3.0)
      sprockets-rails (~> 2.0)

GIT
  remote: git://github.com/syreclabs/ckeditor.git
  revision: f0d175a66876d9b3453fb47a7914789660a36a15
  specs:
    ckeditor (4.0.6)
      mime-types
      orm_adapter

GIT
  remote: https://github.com/bearded-nemesis/heroku-rglpk.git
  revision: 760859ce23c6e9d253324a584da6ee351700c48f
  specs:
    heroku-rglpk (0.2.1)

PATH
  remote: lib/plugins/xeroizer-payroll-merged
  specs:
    xeroizer (2.16.5)
      activesupport
      builder (>= 2.1.2)
      i18n
      nokogiri
      oauth (>= 0.4.5)
      tzinfo

GEM
  remote: http://rubygems.org/
  specs:
    actionmailer (4.0.0)
      actionpack (= 4.0.0)
      mail (~> 2.5.3)
    actionpack (4.0.0)
      activesupport (= 4.0.0)
      builder (~> 3.1.0)
      erubis (~> 2.7.0)
      rack (~> 1.5.2)
      rack-test (~> 0.6.2)
    activemodel (4.0.0)
      activesupport (= 4.0.0)
      builder (~> 3.1.0)
    activerecord (4.0.0)
      activemodel (= 4.0.0)
      activerecord-deprecated_finders (~> 1.0.2)
      activesupport (= 4.0.0)
      arel (~> 4.0.0)
    activerecord-deprecated_finders (1.0.4)
    activesupport (4.0.0)
      i18n (~> 0.6, >= 0.6.4)
      minitest (~> 4.2)
      multi_json (~> 1.3)
      thread_safe (~> 0.1)
      tzinfo (~> 0.3.37)
    addressable (2.3.6)
    annotate (2.6.3)
      activerecord (>= 2.3.0)
      rake (>= 0.8.7)
    arel (4.0.2)
    authlogic (3.4.1)
      activerecord (>= 3.2)
      activesupport (>= 3.2)
      request_store (~> 1.0.5)
    autoparse (0.3.3)
      addressable (>= 2.3.1)
      extlib (>= 0.9.15)
      multi_json (>= 1.0.0)
    awesome_print (1.2.0)
    aws-eventstream (1.0.2)
    aws-partitions (1.149.0)
    aws-sdk (1.38.0)
      json (~> 1.4)
      nokogiri (>= 1.4.4)
      uuidtools (~> 2.1)
    aws-sdk-core (3.48.3)
      aws-eventstream (~> 1.0, >= 1.0.2)
      aws-partitions (~> 1.0)
      aws-sigv4 (~> 1.1)
      jmespath (~> 1.0)
    aws-sdk-kms (1.16.0)
      aws-sdk-core (~> 3, >= 3.48.2)
      aws-sigv4 (~> 1.1)
    aws-sdk-s3 (1.36.0)
      aws-sdk-core (~> 3, >= 3.48.2)
      aws-sdk-kms (~> 1)
      aws-sigv4 (~> 1.0)
    aws-sigv4 (1.1.0)
      aws-eventstream (~> 1.0, >= 1.0.2)
    bcrypt (3.1.7)
    bcrypt-ruby (3.1.5)
      bcrypt (>= 3.1.3)
    builder (3.1.4)
    capybara (2.2.1)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      xpath (~> 2.0)
    celluloid (0.15.2)
      timers (~> 1.1.0)
    celluloid-io (0.15.0)
      celluloid (>= 0.15.0)
      nio4r (>= 0.5.0)
    climate_control (0.0.3)
      activesupport (>= 3.0)
    cocaine (0.5.4)
      climate_control (>= 0.0.3, < 1.0)
    coderay (1.1.0)
    coffee-rails (4.0.1)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.7.0)
    concurrent-ruby (1.1.5)
    daemons (1.1.9)
    dalli (2.7.0)
    database_cleaner (1.2.0)
    delayed_job (4.0.1)
      activesupport (>= 3.0, < 4.2)
    delayed_job_active_record (4.0.1)
      activerecord (>= 3.0, < 4.2)
      delayed_job (>= 3.0, < 4.1)
    diff-lcs (1.2.5)
    dotenv (0.7.0)
    erubis (2.7.0)
    eventmachine (1.0.3)
    exception_notification (4.0.1)
      actionmailer (>= 3.0.4)
      activesupport (>= 3.0.4)
    execjs (2.0.2)
    extlib (0.9.16)
    factory_girl (4.4.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (4.4.1)
      factory_girl (~> 4.4.0)
      railties (>= 3.0.0)
    faraday (0.9.0)
      multipart-post (>= 1.2, < 3)
    ffi (1.9.0)
    ffi-compiler (0.1.3)
      ffi (>= 1.0.0)
      rake
    font_assets (0.1.11)
      rack
    foreigner (1.6.1)
      activerecord (>= 3.0.0)
    foreman (0.64.0)
      dotenv (~> 0.7.0)
      thor (>= 0.13.6)
    formatador (0.2.4)
    google-api-client (0.7.1)
      addressable (>= 2.3.2)
      autoparse (>= 0.3.3)
      extlib (>= 0.9.15)
      faraday (>= 0.9.0)
      jwt (>= 0.1.5)
      launchy (>= 2.1.1)
      multi_json (>= 1.0.0)
      retriable (>= 1.4)
      signet (>= 0.5.0)
      uuidtools (>= 2.1.0)
    grocer (0.5.0)
    guard (2.6.0)
      formatador (>= 0.2.4)
      listen (~> 2.7)
      lumberjack (~> 1.0)
      pry (>= 0.9.12)
      thor (>= 0.18.1)
    guard-rspec (4.2.8)
      guard (~> 2.1)
      rspec (>= 2.14, < 4.0)
    haml (4.0.5)
      tilt
    haml-rails (0.4)
      actionpack (>= 3.1, < 4.1)
      activesupport (>= 3.1, < 4.1)
      haml (>= 3.1, < 4.1)
      railties (>= 3.1, < 4.1)
    hike (1.2.3)
    i18n (0.9.5)
      concurrent-ruby (~> 1.0)
    jmespath (1.4.0)
    jquery-rails (3.1.0)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    jquery-ui-rails (4.2.1)
      railties (>= 3.2.16)
    json (1.8.6)
    jwt (0.1.11)
      multi_json (>= 1.5)
    launchy (2.4.2)
      addressable (~> 2.3)
    listen (2.7.1)
      celluloid (>= 0.15.2)
      celluloid-io (>= 0.15.0)
      rb-fsevent (>= 0.9.3)
      rb-inotify (>= 0.9)
    lumberjack (1.0.5)
    mail (2.5.5)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    memcachier (0.0.2)
    method_source (0.8.2)
    mime-types (1.25.1)
    mini_portile (0.5.3)
    minitest (4.7.5)
    multi_json (1.13.1)
    multipart-post (2.0.0)
    newrelic_rpm (3.7.3.204)
    nio4r (1.2.1)
    nokogiri (1.6.1)
      mini_portile (~> 0.5.0)
    oauth (0.5.3)
    orm_adapter (0.5.0)
    paperclip (3.5.4)
      activemodel (>= 3.0.0)
      activesupport (>= 3.0.0)
      cocaine (~> 0.5.3)
      mime-types
    pg (0.17.1)
    pg_array_parser (0.0.9)
    polyglot (0.3.5)
    postgres_ext (2.0.0)
      activerecord (~> 4.0.0)
      arel (~> 4.0.0)
      pg_array_parser (~> 0.0.9)
    protected_attributes (1.0.3)
      activemodel (>= 4.0.0, < 5.0)
    pry (0.9.12.6)
      coderay (~> 1.0)
      method_source (~> 0.8)
      slop (~> 3.4)
    quiet_assets (1.0.2)
      railties (>= 3.1, < 5.0)
    rack (1.5.5)
    rack-cors (0.2.9)
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (4.0.0)
      actionmailer (= 4.0.0)
      actionpack (= 4.0.0)
      activerecord (= 4.0.0)
      activesupport (= 4.0.0)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.0.0)
      sprockets-rails (~> 2.0.0)
    rails_12factor (0.0.2)
      rails_serve_static_assets
      rails_stdout_logging
    rails_serve_static_assets (0.0.2)
    rails_stdout_logging (0.0.3)
    railties (4.0.0)
      actionpack (= 4.0.0)
      activesupport (= 4.0.0)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (12.3.2)
    rb-fsevent (0.9.4)
    rb-inotify (0.9.3)
      ffi (>= 0.5.0)
    request_store (1.0.5)
    retriable (1.4.1)
    rspec (2.14.1)
      rspec-core (~> 2.14.0)
      rspec-expectations (~> 2.14.0)
      rspec-mocks (~> 2.14.0)
    rspec-core (2.14.8)
    rspec-expectations (2.14.5)
      diff-lcs (>= 1.1.3, < 2.0)
    rspec-mocks (2.14.6)
    rspec-rails (2.14.2)
      actionpack (>= 3.0)
      activemodel (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-core (~> 2.14.0)
      rspec-expectations (~> 2.14.0)
      rspec-mocks (~> 2.14.0)
    rubyzip (1.1.7)
    sass (3.2.19)
    scrypt (1.2.1)
      ffi-compiler (>= 0.0.2)
      rake
    shortener (0.3.0)
      rails (>= 3.0.7)
    signet (0.5.0)
      addressable (>= 2.2.3)
      faraday (>= 0.9.0.rc5)
      jwt (>= 0.1.5)
      multi_json (>= 1.0.0)
    slop (3.5.0)
    spork (0.9.2)
    sprockets (2.12.5)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sprockets-rails (2.0.1)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (~> 2.8)
    strip_attributes (1.5.1)
      activemodel (>= 3.0, < 5.0)
    thin (1.6.2)
      daemons (>= 1.0.9)
      eventmachine (>= 1.0.0)
      rack (>= 1.0.0)
    thor (0.20.3)
    thread_safe (0.3.6)
    tilt (1.4.1)
    timers (1.1.0)
    treetop (1.4.15)
      polyglot
      polyglot (>= 0.3.1)
    trim_blobs (0.0.1)
      activerecord (>= 3.2.0)
    twilio-ruby (3.11.5)
      builder (>= 2.1.2)
      jwt (>= 0.1.2)
      multi_json (>= 1.3.0)
    tzinfo (0.3.55)
    uglifier (2.5.0)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    uuidtools (2.1.4)
    xpath (2.0.0)
      nokogiri (~> 1.3)
    yui-compressor (0.12.0)

PLATFORMS
  ruby

DEPENDENCIES
  annotate
  authlogic
  awesome_print
  aws-sdk
  aws-sdk-s3
  bcrypt-ruby (~> 3.1.2)
  capybara
  ckeditor!
  coffee-rails
  dalli
  database_cleaner
  delayed_job_active_record
  exception_notification
  factory_girl_rails
  ffi (= 1.9.0)
  font_assets
  foreigner
  foreman
  google-api-client
  grocer
  guard-rspec
  haml
  haml-rails
  heroku-rglpk!
  jquery-rails
  jquery-ui-rails
  memcachier
  multipart-post
  newrelic_rpm
  paperclip (~> 3.0)
  pg
  postgres_ext
  protected_attributes
  quiet_assets
  rack-cors
  rails (= 4.0)
  rails_12factor
  rb-fsevent
  rspec
  rspec-core
  rspec-mocks
  rspec-rails
  rubyzip (~> 1.1.0)
  sass-rails!
  scrypt
  shortener
  spork
  strip_attributes
  thin
  trim_blobs
  twilio-ruby
  uglifier
  xeroizer!
  yui-compressor

RUBY VERSION
   ruby 2.1.10p492

BUNDLED WITH
   1.17.3

这是我使用binding.pry打印出“ client_ids”时得到的:

Using activesupport 4.0.0 (was 3.2.18)
Using builder 3.1.4 (was 3.0.4)

Using rack 1.5.5 (was 1.4.5)

Using actionpack 4.0.0 (was 3.2.18)

Using actionmailer 4.0.0 (was 3.2.18)
Using activemodel 4.0.0 (was 3.2.18)

Using activerecord-deprecated_finders 1.0.4

Using arel 4.0.2 (was 3.0.3)
Using activerecord 4.0.0 (was 3.2.18)

Using railties 4.0.0 (was 3.2.18)
Using coffee-rails 4.0.1 (was 3.2.2)

Using postgres_ext 2.0.0 (was 1.0.0)

Using sprockets 2.8.3 (was 2.2.2)
Using sprockets-rails 2.0.1
Using rails 4.0.0 (was 3.2.18)

Using sass 3.2.19 (was 3.3.5)
Using sass-rails 4.0.5 (was 3.2.6)

如果我使用pry拨打该行:

=> [76,
 73,
 64,
 51,
 22,
 67,
 75,
 36,
 83,
 32,
 62,
 55,
 18,
 20,
 60,
 69,
 68,
 1,
 9,
 77,
 78,
 33,
 57,
 59,
 41,
 63,
 43,
 53,
 71,
 66,
 38,
 58,
 61,
 80,
 6,
 65,
 70,
 81,
 74,
 82,
 79,
 42,
 56,
 50,
 49,
 47,
 45,
 44,
 48]

1 个答案:

答案 0 :(得分:1)

您需要升级自己的var d = new Date(); var curr_date = d.getDate(); var curr_month = d.getMonth() + 1; var curr_year = d.getFullYear(); var d1 = curr_date + "/" + curr_month + "/" + curr_year; //alert(d1); change format date completed 12/04/2019 var date2 = new Date("04/12/2018"); var curr_date2 = date2.getDate(); var curr_month2 = date2.getMonth() + 1; var curr_year2 = date2.getFullYear(); var d2 = curr_date2 + "/" + curr_month2 + "/" + curr_year2; //alert(d2); // change format date completed 12/04/2018 if (d1 > d2) { console.log("aaa"); } else { console.log("bbb"); }宝石。

您当前安装了Arel 4.0.2,并安装了PostgresExt 2.0.0。

我看到PostgresExt 2.1.3说“修复Arel 4.0.1问题”。 https://github.com/DavyJonesLocker/postgres_ext/blob/master/CHANGELOG.md#213

您的PostgresExt版本与您安装的Rails版本不兼容。由于您最近添加了stacktrace,我来到了这个顿悟。

postgres_ext

请注意,问题是PostgresExt gem中的参数数量错误。

是否注意到有关此提交的任何有趣信息?

https://github.com/DavyJonesLocker/postgres_ext/commit/4ac6184d4bbfd763044b28f98344a02cf688cca3

采用该from /Users/justin/.rvm/gems/ruby-2.1.10/gems/postgres_ext-2.0.0/lib/postgres_ext/arel/visitors/to_sql.rb:6:in `visit_Array' 方法,并使其使用两个参数而不是1。这就是问题所在。 ActiveRecord试图使用2个参数调用Arel方法,但PostgresExt已覆盖该方法以添加一些功能,并且它们的覆盖仅需要1个参数。这就是为什么这类超越核心功能的宝石使用起来有点危险。您需要良好的测试覆盖率,因为当Rails更改其gem的内部位时,它会迅速破坏此PostgresExt gem。

您还应考虑从该宝石上移走,因为它不再被维护。

我的一个同事最近向我展示了这个名为ActiveRecordExtended的宝石(奇怪的名字,考虑到它仅是Postgres,但是,哦)。我从没使用过它,所以我不能担保它,但是它似乎可以完成PostgesExt的工作,但是也得到了维护。

https://github.com/georgekaraszi/ActiveRecordExtended