更新时间:2023-12-04 18:55:16
该文件应该被称为 stats_controller.rb
应用程序/控制器/ API / stats_controller.rb
您可以创建一个首页
方法,您可以添加您的code
you can create an index
method where you can add your code
class API::StatsController < ApplicationController
def index
#your code here
render json: your_result
end
end
在文件的config / routes.rb中
您应该添加
get 'stats' => 'api/stats#index', as: 'stats'
要访问PARAMS中的网址,你可以用 PARAMS做它在你的索引方法[:位置]
, PARAMS [:状态]
To access the params in the url you can do it in your index method with params[:location]
,params[:state]