小编ric*_*ick的帖子

验证失败:1:批量索引ElasticSearch中未添加任何请求

我有一个JSON文件,我需要在ElasticSearch服务器上对其进行索引.

JSOIN文件如下所示:

{
    "sku": "1",
    "vbid": "1",
    "created": "Sun, 05 Oct 2014 03:35:58 +0000",
    "updated": "Sun, 06 Mar 2016 12:44:48 +0000",
    "type": "Single",
    "downloadable-duration": "perpetual",
    "online-duration": "365 days",
    "book-format": "ePub",
    "build-status": "In Inventory",
    "description": "On 7 August 1914, a week before the Battle of Tannenburg and two weeks before the Battle of the Marne, the French army attacked the Germans at Mulhouse in Alsace. Their objective was to recapture territory which had been lost after the Franco-Prussian War of 1870-71, …
Run Code Online (Sandbox Code Playgroud)

json elasticsearch elasticsearch-bulk-api

16
推荐指数
1
解决办法
2万
查看次数

使用s3 gem + rails 4.1.5时,不允许使用`@@ {'作为类变量名(SyntaxError)

我知道这类问题已经被问到了.

我使用s3gem将我的文件上传到s3存储桶中.但是在s3安装gem 之后,当我启动rails服务器时它会显示以下错误:

    /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:223:in `class_eval': /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:223: `@@{' is not allowed as a class variable name (SyntaxError)
/var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:223: syntax error, unexpected $end
        unless defined? @@{:instance_writer=>true}
                          ^
    from /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:223:in `block in cattr_reader'
    from /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:222:in `each'
    from /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:222:in `cattr_reader'
    from /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:258:in `cattr_accessor'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/cache.rb:155:in `<class:Store>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/cache.rb:154:in `<module:Cache>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/cache.rb:14:in `<module:ActiveSupport>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/cache.rb:12:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `block in require'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from /var/lib/gems/1.9.1/gems/jbuilder-2.2.5/lib/jbuilder/jbuilder_template.rb:3:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from …
Run Code Online (Sandbox Code Playgroud)

ruby amazon-s3 ruby-on-rails-4.2

7
推荐指数
1
解决办法
2506
查看次数

编写ruby代码时haml中=和 - 有什么区别?

所以我是HAML的新手.

在浏览HAML教程时,提到了代表ruby代码的方法 =

例如: %strong= item.title

但是当我运行这段代码时:

= @list.documents.each do |doc|
  %tbody
    %tr
      %td= doc.display_name
Run Code Online (Sandbox Code Playgroud)

除了显示的所有列表数据之外,还显示了很多与显示的实际列表数据相关的垃圾数据.这就是我得到的:

val1 val2 val3 [#Document......@id : val1, @id:val2.....]
Run Code Online (Sandbox Code Playgroud)

当我尝试同样的代码,同时更换=-不必要的数据不被接受.

- @list.documents.each do |doc|
      %tbody
        %tr
          %td= doc.display_name
Run Code Online (Sandbox Code Playgroud)

输出:

val1 val2 val3
Run Code Online (Sandbox Code Playgroud)

谁可以解释-=haml中编写ruby代码之间的区别 ?

ruby haml ruby-on-rails

7
推荐指数
1
解决办法
643
查看次数

Jenkins 中的 hudson.util.HudsonFailedToLoad 错误

当我尝试访问我的 Jenkins 服务器时出现以下错误,

hudson.util.HudsonFailedToLoad: org.jvnet.hudson.reactor.ReactorException: java.lang.Error: java.lang.reflect.InvocationTargetException
at hudson.WebAppMain$3.run(WebAppMain.java:234)
Caused by: org.jvnet.hudson.reactor.ReactorException: java.lang.Error: java.lang.reflect.InvocationTargetException
    at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:269)
    at jenkins.InitReactorRunner.run(InitReactorRunner.java:44)
    at jenkins.model.Jenkins.executeReactor(Jenkins.java:910)
    at jenkins.model.Jenkins.<init>(Jenkins.java:809)
    at hudson.model.Hudson.<init>(Hudson.java:82)
    at hudson.model.Hudson.<init>(Hudson.java:78)
    at hudson.WebAppMain$3.run(WebAppMain.java:222)
Caused by: java.lang.Error: java.lang.reflect.InvocationTargetException
    at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:109)
    at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:169)
    at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:282)
    at jenkins.model.Jenkins$7.runTask(Jenkins.java:899)
    at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:210)
    at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:105)
    ... 8 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
    at com.thoughtworks.xstream.core.util.OrderRetainingMap.entrySet(OrderRetainingMap.java:77)
    at java.util.HashMap.putMapEntries(HashMap.java:511)
    at java.util.HashMap.putAll(HashMap.java:784)
    at com.thoughtworks.xstream.core.util.OrderRetainingMap.<init>(OrderRetainingMap.java:36)
    at …
Run Code Online (Sandbox Code Playgroud)

git jenkins jenkins-plugins

6
推荐指数
1
解决办法
2万
查看次数

抑制 Rspec 3 的回溯

我正在使用 rspec 3.2.0 和 capybara 2.4.4 并在我的 spec_helper.rb 文件中如下所示

config.full_backtrace=false
Run Code Online (Sandbox Code Playgroud)

对于大多数错误,我都会得到回溯,例如

Failure/Error: check 'un_student_3'
 Capybara::ElementNotFound:
   Unable to find checkbox "un_student_3"
 # /Users/115698/.rvm/gems/ruby-2.1.1@match_maker/gems/capybara-2.4.4/lib/capybara/node/finders.rb:41:in `block in find'
 # /Users/115698/.rvm/gems/ruby-2.1.1@match_maker/gems/capybara-2.4.4/lib/capybara/node/base.rb:84:in `synchronize'
 # /Users/115698/.rvm/gems/ruby-2.1.1@match_maker/gems/capybara-2.4.4/lib/capybara/node/finders.rb:30:in `find'
 # /Users/115698/.rvm/gems/ruby-2.1.1@match_maker/gems/capybara-2.4.4/lib/capybara/node/actions.rb:82:in `check'
 # /Users/115698/.rvm/gems/ruby-2.1.1@match_maker/gems/capybara-2.4.4/lib/capybara/session.rb:676:in `block (2 levels) in <class:Session>'
 # /Users/115698/.rvm/gems/ruby-2.1.1@match_maker/gems/capybara-2.4.4/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
 # ./spec/features/students/student_spec.rb:56:in `block (2 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)

我怎样才能关闭它?

rspec ruby-on-rails capybara

5
推荐指数
1
解决办法
508
查看次数

从ruby中的嵌套哈希数组中搜索键值

我有嵌套哈希数组,

@a = [{"id"=>"5", "head_id"=>nil,
         "children"=>
             [{"id"=>"19", "head_id"=>"5",
                 "children"=>
                     [{"id"=>"21", "head_id"=>"19", "children"=>[]}]},
             {"id"=>"20", "head_id"=>"5",
                 "children"=>
                     [{"id"=>"22", "head_id"=>"20", "children"=>[]}, {"id"=>"23"}]
             }]
     }]
Run Code Online (Sandbox Code Playgroud)

我需要所有具有键名称'id'的值的数组.比如@b = [5,19,21,20,22,23]我已经试过这个'@a.find {| h | H [ 'ID']}`.有谁知道如何得到这个?

谢谢.

ruby arrays hash ruby-on-rails

4
推荐指数
1
解决办法
1990
查看次数

从哈希数组中获取基于字符串的唯一元素

我有一系列哈希:

[{:a => "63-aaa",:b =>1}, {:a => "90-bbb",:b => 89}, {:a => "63-aaa", :b => 1},{:a => "45-hhh", :b => 44}, {:a => "32-kkk", :b => 67}, {: => "90-bbb", :b => 89}]
Run Code Online (Sandbox Code Playgroud)

a关键是有价值的63-aaa,90-bbb,45-hhh32-kkk.我希望根据a类似值的ID来获取数组的唯一元素:

[{:a => "63-aaa",:b =>1}, {:a => "90-bbb",:b => 89}, {:a => "45-hhh", :b => 44}, {:a => "32-kkk", :b => 67}]
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails

3
推荐指数
1
解决办法
101
查看次数

如何在Gemfile中安装生产组

我的宝石文件包括:

group :production do
  gem 'pg',             '0.17.1'
  gem 'rails_12factor', '0.0.2'
  gem 'puma',           '2.11.1'
end
Run Code Online (Sandbox Code Playgroud)

当我发出bundle install命令时,最后我得到了这条线

"Your bundle is complete!
Gems in the group production were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed."
Run Code Online (Sandbox Code Playgroud)

如何安装生产组.

ruby gem rubygems ruby-on-rails ruby-on-rails-4

3
推荐指数
1
解决办法
2965
查看次数

在活动管理栏4中的显示页面上更改有关删除操作的确认消息

在我的应用程序中,我需要更改删除操作的默认确认消息.我已在索引页面上更改了删除操作的默认确认消息,例如

index do
  column :title
  column :start_date
  column :start_time
  column :end_date
  column :end_time

  #actions
  actions defaults: false do |post|
    item "View", admin_content_path(post)
    text_node "&nbsp".html_safe
    item "Edit", edit_admin_content_path(post)
    text_node "&nbsp".html_safe
    item "Delete", admin_content_path(post), method: :delete, :confirm => "All grades, uploads and tracks will be deleted with this content.Are you sure you want to delete this Content?"
end
Run Code Online (Sandbox Code Playgroud)

结束

这在索引页面上工作正常.我想在显示页面上更改删除操作的默认确认消息.它仍显示默认消息,例如"您确定要删除此内容吗?"

如何在activeadmin中更改批量操作确认对话框的css?

有人知道吗?谢谢.

ruby-on-rails activeadmin ruby-on-rails-4

1
推荐指数
1
解决办法
3914
查看次数