2021-04-01 10:59:27 +00:00
|
|
|
class AppsController < ApplicationController
|
2021-04-29 06:41:23 +00:00
|
|
|
def index
|
|
|
|
|
authorize App
|
|
|
|
|
@apps = App.where(organization: @current_user.organization).order('created_at desc')
|
|
|
|
|
end
|
2021-04-05 07:49:48 +00:00
|
|
|
|
2021-04-29 06:41:23 +00:00
|
|
|
def create
|
|
|
|
|
authorize App
|
|
|
|
|
@app = App.create({
|
|
|
|
|
name: 'Untitled app',
|
|
|
|
|
organization: @current_user.organization,
|
|
|
|
|
current_version: AppVersion.new(name: 'v0')
|
|
|
|
|
})
|
|
|
|
|
end
|
2021-04-02 11:09:35 +00:00
|
|
|
|
2021-04-29 06:41:23 +00:00
|
|
|
def show
|
|
|
|
|
@app = App.find params[:id]
|
|
|
|
|
authorize @app
|
|
|
|
|
end
|
2021-04-02 11:09:35 +00:00
|
|
|
|
2021-04-29 06:41:23 +00:00
|
|
|
def update
|
|
|
|
|
authorize App
|
|
|
|
|
@app = App.find params[:id]
|
|
|
|
|
@app.update(params['app'].permit('name', 'current_version_id'))
|
|
|
|
|
end
|
2021-04-12 04:12:00 +00:00
|
|
|
|
2021-04-29 06:41:23 +00:00
|
|
|
def users
|
|
|
|
|
@app = App.find params[:app_id]
|
|
|
|
|
@app_users = AppUser.where(app: @app).includes(:user)
|
|
|
|
|
end
|
2021-04-01 10:59:27 +00:00
|
|
|
end
|