我有一个控制器 courses_controller.rb:
以下模型 - coursera.rb:
但是,当我访问http://localhost:3000/courses/index时,我收到以下错误信息:
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 read server certificate B: certificate verify failed
Application Trace | Framework Trace | Full Trace
app/models/coursera.rb:9:in for'
app/controllers/courses_controller.rb:4:in
index'
请告诉我该怎么办。什么都不起作用!