小编mys*_*ola的帖子

Rails 3.2.17运行时错误重定向禁止的facebook

我有这个代码用于从Facebook获取头像...

if auth.info.image.present?
      user.update_attribute(:avatar, URI.parse(auth.info.image))
end
Run Code Online (Sandbox Code Playgroud)

当我尝试加载代码时,我收到此错误:

A RuntimeError occurred in authentications#create:

  redirection forbidden: http://graph.facebook.com/672086173/picture?type=square -> https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn2/t5.0-1/1086349_672086173_156380036_q.jpg
  /home/ubuntu/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/open-uri.rb:223:in `open_loop'
Run Code Online (Sandbox Code Playgroud)

我知道这是Open-URI不允许HTTP到HTTPS重定向的问题...我明白这可以用Open-Uri-Redirections插件解决https://github.com/jaimeiniesta/open_uri_redirections

但有两件事我不明白:

  1. 昨天工作得很好......我什么都没改变.那么,为什么Paperclip突然无法获得正确的URL?
  2. Open-Uri-redirections的说明给出了以下示例:

    打开(' http ://github.com',:allow_redirections =>:safe)

我如何将其与上面的代码进行协调?

redirect facebook open-uri ruby-on-rails-3.2

18
推荐指数
3
解决办法
7897
查看次数

Ruby-on-Rails:ActiveAdmin SuperClass Mismatch TypeError

我只是想安装ActiveAdmin.看起来非常简单.

http://net.tutsplus.com/tutorials/ruby/create-beautiful-administration-interfaces-with-active-admin/

但是当我到rails生成active_admin:install时

我明白了:

$ rails generate active_admin:install
/home/user/active_admin/config/application.rb:13:in `<module:ActiveAdmin>': superclass mismatch for class Application (TypeError)
from /home/user/active_admin/config/application.rb:12:in `<top (required)>'
from /home/user/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.13/lib/rails/commands.rb:24:in `require'
from /home/user/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.13/lib/rails/commands.rb:24:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Run Code Online (Sandbox Code Playgroud)

似乎无法找到有这个问题的其他人.我甚至删除了active_admin并从头开始重新开始整个事情......没有骰子.

ruby-on-rails ruby-on-rails-3 activeadmin

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

Rails:Javascript无法在生产环境中使用

到目前为止,这是我所做的。

  1. 我在Capfile中加载了资源:js仍然无法正常运行 http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets

  2. 我将咖啡架从资产移到了主要部分:仍然无法正常工作

    宝石'咖啡轨','〜> 3.2.1'

    group:assets do gem'sass-rails','〜> 3.2.3'结尾

更新:生产环境

SolidAdmin :: Application.configure do#此处指定的设置将优先于config / application.rb中的设置

  # Code is not reloaded between requests
  config.cache_classes = true

  # Full error reports are disabled and caching is turned on
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  Paperclip.options[:command_path] = "/usr/bin/"
  # Disable Rails's static asset server (Apache or nginx will already do this)
  config.serve_static_assets = false

  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Don't fallback to assets pipeline if a precompiled …
Run Code Online (Sandbox Code Playgroud)

jquery production ruby-on-rails-3

5
推荐指数
2
解决办法
8951
查看次数

FireBase sendMessage 函数更新到 v1 Google Cloud Endpoint

所以......今天早上......我收到一封电子邮件说:

我们的记录显示,您拥有的 App Engine 应用程序或 Cloud Functions 项目仍在调用 App Engine 和 Cloud Functions 元数据服务器的 pre-GA v0.1 和 v1beta1 端点。

我们写信通知您,这些旧端点计划于 2020 年 4 月 30 日被拒绝。2020 年 4 月 30 日之后,将不再支持对 v0.1 和 v1beta1 端点的请求,并且可能返回 HTTP 404未找到响应。

我只使用 Firebase 函数来发送消息......并且电子邮件继续将我的 sendMessage 函数识别为罪魁祸首。但我不能......为了我的生活......弄清楚我需要在哪里更新端点。我的sendMessage函数如下:

exports.sendMessage = functions.database.ref('/messages/{receiverUid}/{senderUid}/{msgId}')
    .onWrite(async (change, context) => {
      const message = change.after.val().body;
      const receiverUid = change.after.val().receiverUid;
      const senderUid = change.after.val().senderUid;
      const msgId = change.after.val().msgId;
      if (!change.after.val()) {
        return console.log('Sender ', senderUid, 'receiver ', receiverUid, 'message ', message);
      } …
Run Code Online (Sandbox Code Playgroud)

firebase google-cloud-endpoints google-cloud-functions

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

带有数据的iOS中的两个单元格

自从我开始使用此应用以来,这一直让我感到非常疯狂.基本上我有一个带有图像和标签的UITableViewCell,我希望在同一行中有另一个UITableViewCell,其下一个结果的图像和标签就在它旁边.

像PrettyKit那样但不使用该框架的东西:

漂亮的套件示例

所以...假设我的数据库返回了四个结果,列是id,text和image.那些结果将是id1,text1,image1,id2,text2,image2,id3,text3,image3,id4,text4,image4:

Image1 | Image2
Text1  | Text2

Image3 | Image4
Text3  | Text4
Run Code Online (Sandbox Code Playgroud)

等等.

我已经有了一个完全符合布局的xib ...而且我知道我可以在一行中并排放置两个按钮...但我不知道如何填充我的图像视图和文本视图以便数据可以是侧面的并排在一排.

有任何想法吗?

更新:决定给UICollectionView一个镜头,因为它似乎是我想要做的最好的解决方案.但是在将TableView转换为CollectionView时遇到了一些麻烦.xcode将UITableView转换为UICollectionView(无效单元格)

uitableview ios

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

部署期间的Capifony错误(OpenSSL :: PKey :: PKeyError:不是公钥"/var/www/.ssh/id_rsa.pub")

我一直收到这个错误 (OpenSSL::PKey::PKeyError: not a public key "/var/www/.ssh/id_rsa.pub")

提前致谢.

我的deploy.rb看起来像这样:

  set :application, "goom"
    set :domain,      "goom@bloom.com"
    set :deploy_to,   "/var/www/goom"
    #set :app_path,    "app"

    set :repository,  "/var/www/goom/.git"
    set :scm,         :git
    set :deploy_via,  :copy
    # Or: `accurev`, `bzr`, `cvs`, `darcs`, `subversion`, `mercurial`, `perforce`, $

    set :model_manager, "doctrine"
    # Or: `propel`

    role :web,        domain                         # Your HTTP server, Apache/etc
    role :app,        domain                         # This may be the same as your$
    role :db,         domain, :primary => true       # This is where Rails migratio$
Run Code Online (Sandbox Code Playgroud)

capistrano ssh-keys capifony

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

一个字符串中的多个变量

我目前有这段代码:

NSString *strURL = [NSString stringWithFormat:@"http://www.sample.com   /phpFile.php?firstname=%@",txtfirstName.text];

NSString *strURL2 = [NSString stringWithFormat:@"http://www.sample.com/phpFile.php?lastname=%@",txtlastName.text];
Run Code Online (Sandbox Code Playgroud)

但问题是,这会创建两个不同的行,我想要一行的名字,姓氏和其他所有内容.

那么可以这样做:

NSString *strURL = [NSString stringWithFormat:@"http://www.sample.com   /phpfile.php?firstname=%@",txtfirstName.text,txtlastName.text,txtheight.text,txtweight.text];
Run Code Online (Sandbox Code Playgroud)

还是我需要做一些更复杂的事情?

提前致谢!

objective-c nsstring

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