Class: RailsAdminContent::Develop::ManagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- RailsAdminContent::Develop::ManagesController
- Defined in:
- app/controllers/rails_admin_content/develop/manages_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #details ⇒ Object
- #edit ⇒ Object
- #edit_column ⇒ Object
- #filter ⇒ Object
- #index ⇒ Object
- #modify_default_value ⇒ Object
- #new ⇒ Object
- #query ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #update_field ⇒ Object
Instance Method Details
#create ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'app/controllers/rails_admin_content/develop/manages_controller.rb', line 42 def create RailsAdminContent::Client.insert(params[:table_name], params[:field]) flash[:success] = "成功添加#{params[:table_name]}一条数据。" rescue Exception => e flash[:errors] = e. ensure redirect_to develop_manage_path(params[:table_name]) end |
#destroy ⇒ Object
66 67 68 69 |
# File 'app/controllers/rails_admin_content/develop/manages_controller.rb', line 66 def destroy RailsAdminContent::Client.delete(params[:id], params[:edit_id]) if params[:edit_id].present? render json: params[:edit_id] end |
#details ⇒ Object
38 39 40 |
# File 'app/controllers/rails_admin_content/develop/manages_controller.rb', line 38 def details @details = RailsAdminContent::Client.conn.origin_query("SHOW TABLE STATUS LIKE '#{params[:id]}'").each end |
#edit ⇒ Object
31 |
# File 'app/controllers/rails_admin_content/develop/manages_controller.rb', line 31 def edit; end |
#edit_column ⇒ Object
33 34 35 36 |
# File 'app/controllers/rails_admin_content/develop/manages_controller.rb', line 33 def edit_column @fields = RailsAdminContent::Client.desc_table params[:id] @sql = RailsAdminContent::Client.show_create_sql params[:id] end |
#filter ⇒ Object
15 16 17 18 |
# File 'app/controllers/rails_admin_content/develop/manages_controller.rb', line 15 def filter session[:query_str] = params[:q] redirect_to action: :query end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/rails_admin_content/develop/manages_controller.rb', line 5 def index @version = RailsAdminContent::Client.conn.origin_query("SELECT VERSION() as version").each end |
#modify_default_value ⇒ Object
71 72 73 74 |
# File 'app/controllers/rails_admin_content/develop/manages_controller.rb', line 71 def modify_default_value RailsAdminContent::Client.modify_table_column_default_value(params[:table], params[:field], params[:value], params[:field_type]) render json: params[:edit_id] end |
#new ⇒ Object
29 |
# File 'app/controllers/rails_admin_content/develop/manages_controller.rb', line 29 def new;end |
#query ⇒ Object
9 10 11 12 13 |
# File 'app/controllers/rails_admin_content/develop/manages_controller.rb', line 9 def query @entries = RailsAdminContent::Client.query(session[:query_str],@page, @per).each if session[:query_str] rescue Exception => e flash[:errors] = e. end |
#show ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/controllers/rails_admin_content/develop/manages_controller.rb', line 20 def show @query_str = "SELECT * FROM #{params[:id]} ORDER BY id DESC" @query_str = RailsAdminContent::Client.compose(params) if params[:field].present? @fields = RailsAdminContent::Client.desc_table params[:id] @entries = RailsAdminContent::Client.query(@query_str,@page, @per) rescue Exception => e flash[:errors] = e. end |
#update ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'app/controllers/rails_admin_content/develop/manages_controller.rb', line 51 def update RailsAdminContent::Client.update(params[:table_name], params[:id], params[:field]) flash[:success] = "更新#{params[:id]}内容成功。" rescue Exception => e flash[:errors] = e. ensure redirect_to develop_manage_path(params[:table_name]) end |
#update_field ⇒ Object
61 62 63 64 |
# File 'app/controllers/rails_admin_content/develop/manages_controller.rb', line 61 def update_field RailsAdminContent::Client.conn.origin_query("UPDATE #{params[:table]} SET #{params[:field]} = REPLACE(REPLACE(REPLACE('#{params[:value]}', '&','&'), '>', '>'), '<', '<') WHERE id = #{params[:id]}") render text: 'success' end |