Files
robbiepaul 298610b5f6
CI / test (3.4.1) (push) Has been cancelled
Initial commit (history cleared)
2026-04-29 11:21:39 +01:00

34 lines
670 B
Ruby

# frozen_string_literal: true
class Api::V1::MobileController < ApplicationController
skip_before_action :authenticated
before_action :mobile_request?
respond_to :json
def show
if params[:class]
model = params[:class].classify.constantize
respond_with model.find(params[:id]).to_json
end
end
def index
if params[:class]
model = params[:class].classify.constantize
respond_with model.all.to_json
else
respond_with nil.to_json
end
end
private
def mobile_request?
if session[:mobile_param]
session[:mobile_param] == "1"
else
request.user_agent =~ /ios|android/i
end
end
end