小编Kat*_*e H的帖子

未能安装Nokogiri宝石

我正在开发一个rails应用程序,允许每个使用帐户的图像附件.我正在使用paperclip和amazon网络服务:

gem 'paperclip'
gem 'aws-sdk'
Run Code Online (Sandbox Code Playgroud)

当我运行bundle install时,我收到以下消息:

extconf失败,退出代码1

Gem files will remain installed in /usr/local/rvm/gems/ruby-2.1.2/gems/nokogiri-1.6.5 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.5/gem_make.out
An error occurred while installing nokogiri (1.6.5), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.5'` succeeds before bundling.
Run Code Online (Sandbox Code Playgroud)

当我尝试运行'gem install nokogiri'时,我收到以下消息:

extconf失败,退出代码1

Gem files will remain installed in /usr/local/rvm/gems/ruby-2.1.2/gems/nokogiri-1.6.5 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.5/gem_make.out
Run Code Online (Sandbox Code Playgroud)

我的操作系统是Mac OS X 10.9.4 Mavericks.这里发生了什么?如何让nokogiri安装和行为正常?

完整堆栈跟踪:

Building native extensions with: '--use-system-libraries'
This could take a while...
ERROR:  Error …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails paperclip nokogiri rvm

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

检测到Heroku不支持的sqlite3 gem

我正在尝试将我的rails应用程序推送到Heroku,并且我一直收到以下错误:

       An error occurred while installing sqlite3 (1.3.8), and Bundler cannot continue.
   Make sure that `gem install sqlite3 -v '1.3.8'` succeeds before bundling.
!
!     Failed to install gems via Bundler.
!     
!     Detected sqlite3 gem which is not supported on Heroku.
!     https://devcenter.heroku.com/articles/sqlite3
!

!     Push rejected, failed to compile Ruby app
Run Code Online (Sandbox Code Playgroud)

这是我的gemfile的样子:

group :devlopment, :test do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
end
Run Code Online (Sandbox Code Playgroud)

有想法该怎么解决这个吗?任何帮助深表感谢!

ruby sqlite postgresql ruby-on-rails heroku

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

充当可投票的javascript投票按钮

我正在使用名为acts_as_votable的gem 来使我的模型可以投票.

目前一切正常.

但每次有人投票支持帖子时,页面都必须刷新.如何在没有页面刷新的情况下让投票工作.我可以添加一个简单的JavaScript吗?

这是我在控制器中的内容:

def vote
  @post = Post.find(params[:post_id])
  @post.liked_by current_user
  respond_to do |format|
    format.html {redirect_to :back }
  end
end
Run Code Online (Sandbox Code Playgroud)

以下是我的看法:

 <%= link_to “like post", like_post_path(@post), method: :put %>
Run Code Online (Sandbox Code Playgroud)

javascript ruby ruby-on-rails ruby-on-rails-4

7
推荐指数
2
解决办法
2764
查看次数

覆盖gem中的模型,添加回调和方法

ActiveRecord在我的应用上安装了声誉系统.我将如何覆盖或向评估模型添加回调/方法?

一般来说,如何为您安装的gem添加任何模型?

ruby gem model ruby-on-rails callback

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

在tableview单元格中选择更改图像 - Swift

我正在尝试在选中时更改单元格内的图像.这是我在视图控制器中的内容:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

let cell = self.tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! CustomTableViewCell

        cell.bgImage.image = UIImage(named: "second_image")

}
Run Code Online (Sandbox Code Playgroud)

这是我设置图像的地方:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

let cell = self.tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! CustomTableViewCell

cell.bgImage.image = UIImage(named: "first_image")

}
Run Code Online (Sandbox Code Playgroud)

当我选择单元格时,图像不会更新.我如何让它工作?

uitableview ios swift

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

将变量传递给块 - Rails

在我的rails应用程序中,我使用此gem与Gmail API进行交互:https://github.com/gmailgem/gmail

以下是我发送电子邮件的方法:

gmail = Gmail.connect(params[:email], params[:password])
@email = params[:email]

email = gmail.compose do
  to @email
  subject "Having fun in Puerto Rico!"
  body "Spent the day on the road..."
end
email.deliver!
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

An SMTP To address is required to send a message. Set the message smtp_envelope_to, to, cc, or bcc address.
Run Code Online (Sandbox Code Playgroud)

电子邮件变量无法传递到块中.是什么造成的?如何传递动态电子邮件地址?

ruby ruby-on-rails

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

Rails中的人类可读日期

我想在我的rails应用程序中的视图中显示当前日期.我想要以下格式:星期几,月,日,年.

目前我正在使用:

<%= Time.now.strftime("%B %d, %Y") %>
Run Code Online (Sandbox Code Playgroud)

这显示除了星期几之外的所有内容.如何添加星期几?

ruby time ruby-on-rails date

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

外围没有连接 - 斯威夫特

在我的Swift应用程序中,我有一个应该找到蓝牙设备并连接到它的视图.蓝牙设备已开机.我能够扫描并找到该设备,然后我调用该功能连接到它,但我得不到任何反馈.我不确定为什么它无法连接.

didFailToConnectPeripheral或didConnectPeripheral都没有返回任何值.

我如何让它工作?

import UIKit
import CoreBluetooth

class ViewController: UIViewController, CBCentralManagerDelegate, CBPeripheralDelegate {

    var manager: CBCentralManager!


    override func viewDidLoad() {
        super.viewDidLoad()
        manager = CBCentralManager (delegate: self, queue: nil)
    }


    func centralManager(central: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData: [String : AnyObject], RSSI: NSNumber) {

        print("Peripheral: \(peripheral)")

        manager.connectPeripheral(peripheral, options:nil)

        manager.stopScan()

    }



    func centralManager(central: CBCentralManager, didConnectPeripheral peripheral: CBPeripheral) {
        print("connected!")
    }

    func centralManager(central: CBCentralManager, didDisconnectPeripheral
        peripheral: CBPeripheral, error: NSError?) {
            print("disconnected!")
    }


    func centralManager(central: CBCentralManager,
        didFailToConnectPeripheral peripheral: CBPeripheral, error: NSError?) {
            print("failed")
    }


    func …
Run Code Online (Sandbox Code Playgroud)

core-bluetooth bluetooth-lowenergy cbperipheral swift cbperipheralmanager

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

用户标记自动链接 - Rails

在我的rails应用程序中.我正在尝试写一个帮助,在评论和链接中auto_links提到一个."@someusername"user_path("@someusername")

我怎样才能做到这一点?

我可以自定义auto_link帮手吗?

ruby regex ruby-on-rails ruby-on-rails-4

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

Android WebView在浏览器中打开链接而不是应用程序

我按照本教程:http://examples.javacodegeeks.com/android/core/ui/webview/android-webview-example/

每次我点击webview中的链接时,它都会将我带出webview并进入单独的浏览器窗口.如何在Webview中打开所有链接?

android android-webview android-studio

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

UIBarButtonItem是蓝色而不是图像

这是我在viewDidLoad方法中的内容:

self.navigationController?.navigationBar.backIndicatorImage = UIImage(named: "back")
self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage(named: "back")
self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)
Run Code Online (Sandbox Code Playgroud)

我想在我的导航控制器中为我的后退按钮设置一个自定义图标图像.我没有看到以原始格式显示的图像,而是看到蓝色的图像.如何正确显示图像?

uibarbuttonitem ios swift

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

评论多个模型

在我的rails应用程序中,我目前有评论设置,以使用我的帖子模型,它正常运行.如何在我的图书模型中添加评论?

这是我到目前为止:

以下是我的架构中的评论内容:

 create_table "comments", force: true do |t|
    t.text     "body"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "user_id"
    t.integer  "post_id"
    t.integer  "book_id"
  end
Run Code Online (Sandbox Code Playgroud)

在我的用户模型中:

class User < ActiveRecord::Base
  has_many :comments
  acts_as_voter
end
Run Code Online (Sandbox Code Playgroud)

在我的帖子模型中:

class Post < ActiveRecord::Base
  has_many :comments
end
Run Code Online (Sandbox Code Playgroud)

在我的书模型中:

class Book < ActiveRecord::Base
  has_many :comments
end
Run Code Online (Sandbox Code Playgroud)

在我的评论模型中:

class Comment < ActiveRecord::Base
  belongs_to :post
  belongs_to :book
  belongs_to :user
  acts_as_votable
end
Run Code Online (Sandbox Code Playgroud)

在我的评论控制器中:

class CommentsController < ApplicationController
  def create
    post.comments.create(new_comment_params) do |comment|
      comment.user = current_user
    end
    respond_to do |format|
    format.html {redirect_to post_path(post)} …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails crud ruby-on-rails-4

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