class ConnectsController < ApplicationController before_action :set_connect, only: [:show, :edit, :update, :destroy] layout 'report' def index @connects = Connect.all end def show end def new @connect = Connect.new end def edit end def create @connect = Connect.new(connect_params) respond_to do |format| if @connect.save format.html { redirect_to connects_url, notice: '添加成功' } else format.html { render :new } end end end def update respond_to do |format| if @connect.update(connect_params) format.html { redirect_to connects_url, notice: '修改成功' } else format.html { render :edit } end end end def destroy @connect.destroy respond_to do |format| format.html { redirect_to connects_url, notice: '删除成功' } end end private def set_connect @connect = Connect.find(params[:id]) end def connect_params params.require(:connect).permit(:name, :adapter, :database, :username, :password, :host, :port) end end