Class: BjondRegistrationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- BjondRegistrationsController
- Defined in:
- app/controllers/bjond_registrations_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /bjond_registrations.
-
#destroy ⇒ Object
DELETE /bjond_registrations/1.
-
#edit ⇒ Object
GET /bjond_registrations/1/edit.
-
#index ⇒ Object
GET /bjond_registrations.
-
#new ⇒ Object
GET /bjond_registrations/new.
-
#show ⇒ Object
GET /bjond_registrations/1.
-
#update ⇒ Object
PATCH/PUT /bjond_registrations/1.
Instance Method Details
#create ⇒ Object
POST /bjond_registrations
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/bjond_registrations_controller.rb', line 28 def create @bjond_registration = BjondRegistration.find_or_initialize_by(bjond_registration_params) uri = URI.parse(@bjond_registration.server) @bjond_registration.ip = Resolv.getaddress(uri.host) @bjond_registration.host = Resolv.getname(@bjond_registration.ip) response = BjondApi.register_app(BjondApi::BjondAppConfig.instance.active_definition, @bjond_registration.server) if (response.status == 500) throw "Unable to register with Bjond. \n" + response.body end if @bjond_registration.save redirect_to @bjond_registration, notice: 'Bjönd registration was successfully created.' else render :new end end |
#destroy ⇒ Object
DELETE /bjond_registrations/1
57 58 59 60 |
# File 'app/controllers/bjond_registrations_controller.rb', line 57 def destroy @bjond_registration.destroy redirect_to bjond_registrations_url, notice: 'Bjönd registration was successfully destroyed.' end |
#edit ⇒ Object
GET /bjond_registrations/1/edit
24 25 |
# File 'app/controllers/bjond_registrations_controller.rb', line 24 def edit end |
#index ⇒ Object
GET /bjond_registrations
8 9 10 11 |
# File 'app/controllers/bjond_registrations_controller.rb', line 8 def index @bjond_registrations = BjondRegistration.all @app_info = BjondApi::BjondAppConfig.instance.active_definition end |
#new ⇒ Object
GET /bjond_registrations/new
19 20 21 |
# File 'app/controllers/bjond_registrations_controller.rb', line 19 def new @bjond_registration = BjondRegistration.new end |
#show ⇒ Object
GET /bjond_registrations/1
14 15 16 |
# File 'app/controllers/bjond_registrations_controller.rb', line 14 def show @services = BjondService.where(:bjond_registration_id => @bjond_registration.id) end |
#update ⇒ Object
PATCH/PUT /bjond_registrations/1
48 49 50 51 52 53 54 |
# File 'app/controllers/bjond_registrations_controller.rb', line 48 def update if @bjond_registration.update(bjond_registration_params) redirect_to @bjond_registration, notice: 'Bjönd registration was successfully updated.' else render :edit end end |