【发布时间】:2018-01-13 00:07:03
【问题描述】:
我目前有一个名为 example.rb 的简单 ruby 文件。如何制作允许用户将信息提交到表单中的视图,然后将来自 GET 请求的信息返回给他们?我了解如何从控制台使用这些请求,而不是从前端。
也非常感谢有关此主题的资源。
require 'rubygems'
require 'httparty'
class StackExchange
include HTTParty
base_uri 'api.stackexchange.com'
def initialize(service, page)
@options = {query: {site: service}}
end
def questions
self.class.get('/2.2/questions', @options)
end
def users
self.class.get('/2.2/users', @options)
end
end
stack_exchange = StackExchange.new('stackoverflow',1)
puts stack_exchange.users
【问题讨论】:
标签: ruby-on-rails frontend httparty