26 lines
649 B
Ruby
26 lines
649 B
Ruby
class InstanceController < ApplicationController
|
|
def create
|
|
zone = create_instance_params
|
|
public_id = Nanoid.generate(size: 6)
|
|
name = Spicy::Proton.pair(" ")
|
|
password = Nanoid.generate(size: 3, alphabet: "0123456789")
|
|
instance = Instance.new(zone: zone, public_id: public_id, name: name, password: password)
|
|
if instance.save
|
|
redirect_to(show_instance_path(public_id: public_id))
|
|
end
|
|
end
|
|
|
|
def show
|
|
@instance = Instance.find_by(public_id: show_instance_params)
|
|
end
|
|
|
|
private
|
|
|
|
def create_instance_params
|
|
params.expect(:zone)
|
|
end
|
|
|
|
def show_instance_params
|
|
params.expect(:public_id)
|
|
end
|
|
end
|