小编Abh*_*nay的帖子

bash:./ studio.sh:权限被拒绝(安装Android-Studio时出错)

当我尝试安装Android-Studio并执行命令时

@abhinay-Pc:/android-studio/bin$`./studio.sh
Run Code Online (Sandbox Code Playgroud)

它显示错误:

bash: ./studio.sh: Permission denied
Run Code Online (Sandbox Code Playgroud)

我已经将Java目录导出到了文件/android-studio/bin夹`

(Java_Home = /usr/lib/jvm/java-7-oracle)
Run Code Online (Sandbox Code Playgroud)

我在我的系统上安装了java-7.

bash android intellij-idea android-studio

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

从模型重建索引后,Searchkick索引为空

当我尝试从模型内部重新索引记录时,它最终会在elasticsearch服务器上设置一个空索引.

所以,我有一个Course有很多的模型Instructors.现在,我在instructor.rb模型中有这个回调方法,它会在更新某些内容时尝试重新索引Instructor.

class Instructor < ActiveRecord::Base
belongs_to :teacher, :class_name => "User", :foreign_key => "user_id"
belongs_to :instructorable, polymorphic: true
after_commit :reindex_course

private

  def reindex_course
     Course.reindex_course
  end
end
Run Code Online (Sandbox Code Playgroud)

course.rb 模型看起来像这样:

    class Course < ActiveRecord::Base
        has_many :instructors, as: :instructorable, dependent: :destroy

searchkick word_start: [ :name, :description, :instructor_name]

def search_data
      {
      name: name,
      description: description,
      searchable: searchable,
      }.merge(
        instructor_name: instructors.includes(:teacher).pluck(:'users.name').reject(&:nil?),
      institute_id: creator.try(:institute_id)
)
            def self.reindex_course
                index = Course.reindex(async: true, refresh_interval: "5s")
                Course.search_index.promote(index[:index_name], update_refresh_interval: true)
                Course.search_index.clean_indices
              end …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails elasticsearch searchkick

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

使用Ruby 2.0.0-p353在mac osx雪豹上安装nokogiri gem的问题

我尝试使用自制软件和macports在我的rvm ruby​​ 2.0.0-p353上安装nokogiri,按照nokogiri安装页面上的说明进行操作:

http://nokogiri.org/tutorials/installing_nokogiri.html

在两者中,我得到完全相同的错误文件描述符错误消息,如下所示:

? sudo gem install nokogiri
Fetching: mini_portile-0.5.2.gem (100%)
Successfully installed mini_portile-0.5.2
Fetching: nokogiri-1.6.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb
/Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:292:in `initialize_copy': Bad file descriptor (Errno::EBADF)
    from /Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:292:in `initialize_dup'
    from /Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:292:in `dup'
    from /Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:292:in `<module:Logging>'
    from /Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:289:in `<module:MakeMakefile>'
    from /Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:47:in `<top (required)>'
    from /Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from extconf.rb:5:in `<main>'

extconf failed, exit code 1
Run Code Online (Sandbox Code Playgroud)

搜索此错误会导致与jRuby相关的信息非常少,但我使用的是MRI.

macos gem nokogiri ruby-2.0

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

使用CURL for Rails App的POST请求

这个问题已经被很多用户问到了,我已经尝试了所有解决方案,但都没有解决。例如:这个问题在这里通过终端向Rails应用程序卷曲json post请求,但结果仍然相同。

我正在尝试通过运行以下命令,使用CURL通过终端发布数据:

curl -i -H 'Authorization: Token token'="9asdadsasd87t8ddaghsd" -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"request":{"sender_mobile":"12331212","recipient_mobile":"121231231","location":"Bangalore"}}'  http://localhost:3000/api/v1/requests
Run Code Online (Sandbox Code Playgroud)

和得到回应:

HTTP/1.1 422 Unprocessable Entity 
Content-Type: text/html; charset=utf-8
Content-Length: 15450
X-Request-Id: f1025e69-9ff3-4bd1-9bd5-0679fbcc50bc
X-Runtime: 0.062784
Server: WEBrick/1.3.1 (Ruby/2.1.1/2014-02-24)
Date: Thu, 08 Jan 2015 10:35:45 GMT
Connection: Keep-Alive
Run Code Online (Sandbox Code Playgroud)

有这么多行的垃圾,但我想这个反应足以理解可能是什么原因。这里是完整错误的链接http://pastebin.com/n342HeYL

我可以使用以下命令成功执行GET请求:

curl -i 'http://localhost:3000/api/v1/requests' -H 'Authorization: Token token'="952aa4598ec2cd87c8b69056616a00af"
Run Code Online (Sandbox Code Playgroud)

响应:

HTTP/1.1 200 OK 
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Content-Type: application/json; charset=utf-8
Etag: "b956523e0345d2bb466d39823195b600"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: 91d21235-246f-4557-a67a-92dca02b9cc1 …
Run Code Online (Sandbox Code Playgroud)

ruby curl ruby-on-rails-4

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

目前尚未安装程序"bundle"

虽然我试图运行此代码"捆绑安装 - 没有生产"我收到一个错误,如"程序'包'目前没有安装.您可以通过键入以下来安装它:sudo apt-get install ruby​​-bundler"I已安装捆绑但仍然收到此错误.

这个问题发生在我从Harlt学习的时候发生的..在Heroku设置部分"更新Gemfile"

gem ruby-on-rails bundler

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

ArgumentError:Ruby中的参数数量错误

试图解决这个问题,

  class Person
      def initialize(name)
        @name=name
      end

      def greet(other_name)
       puts "Hi #{other_name}, my name is #{name}"
      end
    end

    initialize("ak")
    greet("aks")
Run Code Online (Sandbox Code Playgroud)

但我得到的错误如下:

ArgumentError: wrong number of arguments calling `initialize` (1 for 0)
Run Code Online (Sandbox Code Playgroud)

我不明白在这里问什么,如果它只是争论那么为什么错误就像(1为0).有人可以帮助我理解这个问题.

ruby

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

使用Youtube iframe API时处理关键事件

我正在寻找一个解决方案,使用Youtube iframe API在我的应用程序上运行Youtube视频时如何处理关键事件.遗憾的是找不到任何东西.已经浏览了这个文档https://developers.google.com/youtube/iframe_api_reference#Events但似乎玩家不会触发任何与密钥相关的事件(例如:onkeydown,keypress,keyup).

我尝试将事件直接添加到提供的代码,但它没有用.

 var tag = document.createElement('script');

      tag.src = "https://www.youtube.com/iframe_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

      // 3. This function creates an <iframe> (and YouTube player)
      //    after the API code downloads.
      var player;
      function onYouTubeIframeAPIReady() {
        player = new YT.Player('trailer_video', {
          height: '390',
          width: '640',
          videoId: 'M7lc1UVf-VE',
          events: {
            // 'onReady': onPlayerReady,
            'onStateChange': onPlayerStateChange,
            'onkeydown': myfunction    // custom event 
          }
        });
      }
Run Code Online (Sandbox Code Playgroud)

有什么办法可以在按下箭头键时特别处理键事件吗?

PS:我不知道我可能在这里错了,但通常当我在视频缓冲时按箭头键时,我看到一串点移动给了我一个暗示,玩家确实检测到这些事件并做出响应.

更新问题

由于下面的答案表明哪种方式在某种程度上是一种解决方案,但由于Youtube还处理左右箭头键事件,当光标在视频上时也可以使用它,我关注的是,我如何处理上下事件箭头键没有被Youtube处理,只有当我实现自定义事件处理程序时光标不在视频上才能工作.

javascript youtube-api youtube-iframe-api

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

路由错误::没有路由匹配[GET]"/ static_pages/about"

我在阅读Michael Hartl的教程时遇到了这个错误.第5.3.2节(Rails路由).

我的routes.rb文件的内容是

SampleApp::Application.routes.draw do
   root  'static_pages#home'
  match '/help',    to: 'static_pages#help',    via: 'get'
  match '/about',   to: 'static_pages#about',   via: 'get'
  match '/contact', to: 'static_pages#contact', via: 'get'
end
Run Code Online (Sandbox Code Playgroud)

我在static_pages的rspec是成功的..我已经按照每条指令但在尝试访问任何页面时仍然遇到此错误

http://localhost:3000/static_pages/home
http://localhost:3000/static_pages/about
http://localhost:3000/static_pages/contact
Run Code Online (Sandbox Code Playgroud)

这是我在这些页面上遇到的错误

动作控制器:捕获异常

Routing Error
No route matches [GET] "/static_pages/about"

Rails.root: /home/abhinay/rails_projects/sample_app

Application Trace | Framework Trace | Full Trace
Routes

Routes match in priority from top to bottom



  Helper     HTTP Verb  Path             Controller#Action
    Path / Url          
    root_path     GET       /                    static_pages#home
    help_path     GET      /help(.:format)   static_pages#help
    about_path    GET …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails custom-routes railstutorial.org

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