小编Sim*_*ton的帖子

如何让Redis从Heroku开始?

我已经Redistogo在Heroku上添加了nano附加组件,并且我已经在控制台中成功测试了它.但是,当我的应用程序尝试与Redis连接时,我收到以下错误:

Heroku日志文件:

2011-10-12T08:19:50+00:00 app[web.1]: Errno::ECONNREFUSED (Connection refused - Unable to connect to Redis on 127.0.0.1:6379):
2011-10-12T08:19:50+00:00 app[web.1]:   app/controllers/sessions_controller.rb:14:in `create'
Run Code Online (Sandbox Code Playgroud)

为什么要尝试在localhost上访问Redis?

config/initializers文件夹中的我的Redis.rb有这个,这几乎肯定是问题所在.

#What's pasted below is pasted ad verbatim. I don't know what to change the values to.

uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails heroku redis

18
推荐指数
2
解决办法
6003
查看次数

在这个Ruby示例中,如何限制重试和救援?

在简陋的Ruby书中,提供了使用Rescue和retry的示例,使用以下代码将HTTP标头发送到服务器:

def make_request
  if (@http11)
    self.send('HTTP/1.1')
  else
    self.send('HTTP/1.0')
  end
rescue ProtocolError
  @http11 = false
  retry
end
Run Code Online (Sandbox Code Playgroud)

要限制一个无限循环以防它无法解析,我必须插入什么代码才能重试5次?会是这样的:

5.times { retry }
Run Code Online (Sandbox Code Playgroud)

ruby

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

如何在1.9.2上安装SystemTimer?

我刚刚使用RVM将我的应用程序从1.8.7升级到1.9.2,不得不添加RubyGems和Bundler,运行bundle install并使一切工作除了SystemTimer.Google-fu什么都不返回,我看到其他人在1.9中遇到了问题,但有些人已经开始工作了.有任何想法吗?

pawel:bodb pawel$ sudo gem install SystemTimer
Building native extensions.  This could take a while...
/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/ext/builder.rb:48: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
ERROR:  Error installing SystemTimer:
ERROR: Failed to build gem native extension.

/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
creating Makefile

make
/usr/bin/gcc-4.2 -I. -I/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-darwin10.3.0
-I/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I.
-D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers
-Wshorten-64-to-32 -Wno-long-long  -fno-common -pipe  -o system_timer_native.o -c system_timer_native.c
In file included from system_timer_native.c:8:
/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete
system_timer_native.c: …
Run Code Online (Sandbox Code Playgroud)

ruby rubygems rvm ruby-on-rails-3

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

为什么动画gif图像需要很长时间才能加载?

为什么简单的动画gif图像在浏览器中开始动画制作之前需要很长时间才能加载,即使文件大小小于已经加载到同一页面上的其他非动画图像文件的累积文件大小?

browser animated-gif

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

React没有响应按键事件

我正在尝试实施一些非常基本的按键检测,我根本无法使用它.我有一个应该在onKeyDown事件中获取的裸组件,但在控制台中没有任何内容被注销:

class App extends React.Component {
  constructor(props) {
    super(props);
  }

  handleKeyDown(event) {
    console.log('handling a key press');
  }

  render() {
    return (
      <ChildComponent onKeyDown={this.handleKeyDown} />
    );
  }
}

React.render(<App />, document.getElementById('app'));
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

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

如何让考拉与Omniauth一起玩得很好?

我正试图让考拉与Omniauth合作.用户模型使用Omniauth登录Facebook,我想使用Koala作为客户端来提取正在使用该应用程序的用户的朋友列表.我似乎没有正确保存令牌:

调节器

@friends = Array.new
 if current_user.token
   graph = Koala::Facebook::GraphAPI.new(current_user.token)
   @profile_image = graph.get_picture("me")
   @fbprofile = graph.get_object("me")
   @friends = graph.get_connections("me", "friends")
end
Run Code Online (Sandbox Code Playgroud)

DB Schema

create_table "users", :force => true do |t|
  t.string   "provider"
  t.string   "uid"
  t.string   "name"
  t.datetime "created_at"
  t.datetime "updated_at"
  t.string   "token"
end
Run Code Online (Sandbox Code Playgroud)

用户模型有

def self.create_with_omniauth(auth)  
  create! do |user|  
    user.provider = auth["provider"]  
    user.uid = auth["uid"]  
    user.name = auth["user_info"]["name"]  
  end  
end
Run Code Online (Sandbox Code Playgroud)

Koala.rb初始化程序有:

module Facebook
  CONFIG = YAML.load_file(Rails.root.join("config/facebook.yml"))[Rails.env]
  APP_ID = CONFIG['app_id']
  SECRET = CONFIG['secret_key']
end

Koala::Facebook::OAuth.class_eval do
  def initialize_with_default_settings(*args)
    case args.size
      when …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails facebook-graph-api omniauth ruby-on-rails-3 koala

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

Resque工作者使用PostgreSQL服务器失败

我已经成功设置了我的工作人员,他们曾经没有问题(在开发中)执行,但现在他们不在生产或开发中(我猜测从SQlite3更改为PostgreSQL之后).

当我运行rake命令来运行worker时,rake resque:work QUEUE=*我得到以下错误和堆栈跟踪:

getaddrinfo: nodename nor servname provided, or not known
Run Code Online (Sandbox Code Playgroud)

heroku rake resque:work QUEUE=*在控制台中运行时,我会遇到以下错误,以测试队列中的待处理工作程序.

Class         SentimentJob
Arguments     [4, 5, 6]
Exception     ActiveRecord::StatementInvalid
Error         PGError: server closed the connection unexpectedly This probably means
              the server terminated abnormally before or while processing the request.
              : SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc,
              a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid =
              d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '"taggings"'::regclass
              AND a.attnum > 0 AND NOT a.attisdropped …
Run Code Online (Sandbox Code Playgroud)

postgresql ruby-on-rails heroku resque redis

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

Go中的仿制药会是什么?

最近有很多关于Golang的批评,因为它不支持泛型.这到底是什么意思呢?您如何向来自Ruby等动态类型语言的人解释这一点,这不是一个熟悉的概念?

go

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

为什么 Heroku 拒绝这个 git 推送?

我使用以下命令在当前应用程序目录中创建了一个新的 Heroku 应用程序Heroku create并运行:

MyMac:bodb pawel$ git push heroku master
Counting objects: 359, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (291/291), done.
Writing objects: 100% (359/359), 13.83 MiB | 2 KiB/s, done.
Total 359 (delta 40), reused 0 (delta 0)

 !     Heroku push rejected due to an unrecognized error.
 !     We've been notified, see http://support.heroku.com if the problem persists.

To git@heroku.com:myproject.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails heroku ruby-on-rails-3

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

OG 标签不适用于 react-helmet 和 Netlify

我一生都无法弄清楚这一点。以下站点托管在 Netlify 上并启用了预渲染。检查页面时,所有 OG 标签都是正确的。这些标签是使用 react-helmet 注入的。

https://browniepoints.africa/opportunities/volunteer-at-a-soup-kitchen-every-week-on-thursdays

在 Facebook 调试器上抓取上述 URL 时,它会响应:

The following required properties are missing: og:url, og:type, og:title, og:image, og:description, fb:app_id
Run Code Online (Sandbox Code Playgroud)

唯一应该存在的错误/警告之一是app_id,我不在乎。

我已经等了 48 多个小时才清除缓存,我尝试使用附加到 URL 的查询字符串进行抓取,并且图像具有绝对 URL。但即使是描述标签也没有通过。

请使用 react-helmet 和 Netlify 的人对这个问题有明确的认识吗?

prerender facebook-opengraph netlify react-helmet

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