RailsRestApi-JSON
小于 1 分钟
RailsRestApi-JSON
bin/rails g controller api/user
config/routes.rb
namespace :api do
resources :user do
end
end
- bin/rails routes
- action json
def index
@users = User.all
render json:@users
end
- url
http://0.0.0.0:3000/api/user