gpt4 book ai didi

html - Ruby on Rails SSL_connect 错误

转载 作者:数据小太阳 更新时间:2023-10-29 08:11:26 26 4
gpt4 key购买 nike

我有以下 Controller - courses-controller.rb:

class CoursesController < ApplicationController
def index
@search_term = params[:looking_for] || 'jhu'
@courses = Coursera.for(@search_term)
end
end

以下模型 - coursera.rb:

class Coursera
include HTTParty

base_uri 'https://api.coursera.org/api/catalog.v1/courses'
default_params fields: "smallIcon,shortDescription", q: "search"
format :json

def self.for term
get("", query: { query: term})["elements"]
end
end

然后查看 index.html.erb:

<h1>Searching for - <%= @search_term %></h1>

<table border="1">
<tr>
<th>Image</th>
<th>Name</th>
<th>Description</th>
</tr>
<% @courses.each do |course| %>
<tr class=<%= cycle('even', 'odd') %>>
<td><%= image_tag(course["smallIcon"])%></td>
<td><%= course["name"] %></td>
<td><%= course["shortDescription"] %></td>
</tr>
<% end %>
</table>

但是,当我做 http://localhost:3000/courses/index ,我收到以下错误:

SSL_connect returned=1 errno=0 state=SSLv3 读取服务器证书 B:证书验证失败应用跟踪 |框架跟踪 |全迹app/models/coursera.rb:9:in for'
app/controllers/courses_controller.rb:4:in
index'

请告诉我该怎么做。什么都没用!

最佳答案

它看起来像是在提示没有有效的证书?如果是这种情况,您可以告诉 HTTParty 暂时忽略无效证书,如下所示:

class Coursera
include HTTParty

default_options.update(verify: false)

...

如果可行,那么您可能想弄清楚为什么它认为证书无效。

关于html - Ruby on Rails SSL_connect 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36798135/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com