Class: WcoHosting::ServerhostsController
- Inherits:
-
ApplicationController
- Object
- Wco::ApplicationController
- ApplicationController
- WcoHosting::ServerhostsController
- Defined in:
- app/controllers/wco_hosting/serverhosts_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/wco_hosting/serverhosts_controller.rb', line 4 def create @serverhost = WcoHosting::Serverhost.new params[:serverhost].permit! :create, @serverhost @serverhost.do_create_server! unless params[:skip_do_resource] flag = @serverhost.save if flag flash[:notice] = 'Success.' redirect_to action: :index else flash[:alert] = "Cannot create serverhost: #{@serverhost.errors.full_messages.join(', ')}." render action: :index end end |
#destroy ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/wco_hosting/serverhosts_controller.rb', line 20 def destroy @serverhost = WcoHosting::Serverhost.find params[:id] :destroy, @serverhost out = HTTParty.delete( "https://api.digitalocean.com/v2/droplets/#{@serverhost.do_id}", headers: { 'Authorization' => "Bearer #{DO_READER_TOKEN}" }, :debug_output => $stdout, ); puts! out, 'out' flag = @serverhost.destroy! if flag flash_notice @serverhost else flash_alert @serverhost end redirect_to action: :index end |
#edit ⇒ Object
37 38 39 40 |
# File 'app/controllers/wco_hosting/serverhosts_controller.rb', line 37 def edit @serverhost = WcoHosting::Serverhost.find params[:id] :edit, @serverhost end |
#index ⇒ Object
42 43 44 45 46 |
# File 'app/controllers/wco_hosting/serverhosts_controller.rb', line 42 def index :index, WcoHosting::Serverhost @serverhosts = WcoHosting::Serverhost.all.order_by name: :asc @new_serverhost = WcoHosting::Serverhost.new end |
#new ⇒ Object
48 49 50 51 |
# File 'app/controllers/wco_hosting/serverhosts_controller.rb', line 48 def new :index, WcoHosting::Serverhost @new_serverhost = WcoHosting::Serverhost.new end |
#show ⇒ Object
53 54 55 56 57 58 |
# File 'app/controllers/wco_hosting/serverhosts_controller.rb', line 53 def show @serverhost = WcoHosting::Serverhost.find params[:id] :show, @serverhost @files = @serverhost.files end |
#update ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/wco_hosting/serverhosts_controller.rb', line 60 def update @serverhost = WcoHosting::Serverhost.find params[:id] :update, @serverhost if @serverhost.update_attributes( params[:serverhost].permit! ) flash_notice @serverhost else flash_alert @serverhost end redirect_to action: :index end |