Commit 85080706 by mingyuan

enum

parent 67cff799
module Dingtalk module Dingtalk
class Admin::AppsController < Admin::BaseController class Admin::AppsController < Admin::BaseController
before_action :set_new_app, only: [:new, :create]
before_action :set_app, only: [:show, :edit, :update, :destroy]
def index def index
@apps = App.page(params[:page]) @apps = App.page(params[:page])
end end
private private
def set_app def app_permit_params
@app = App.find(params[:id]) [
end :type,
def set_new_app
@app = App.new(app_params)
end
def app_params
params.fetch(:app, {}).permit(
:name, :name,
:corp_id, :corp_id,
:agent_id, :agent_id,
:app_key, :app_key,
:app_secret :app_secret
) ]
end end
end end
......
module Dingtalk
class NormalApp < App
end
end
<%= form_with model: @app, url: { action: 'update' } do |f| %>
<%= render partial: 'form', locals: { f: f } %>
<%= f.submit %>
<% end %>
<%= render 'error_messages', target: f.object %>
<%= f.text_field :name %>
<%= f.text_field :corp_id %>
<%= f.text_field :agent_id %>
<%= f.text_field :app_key %>
<%= f.text_field :app_secret %>
<%= form_with model: @app, url: { action: 'create' } do |f| %>
<%= render partial: 'form', locals: { f: f } %>
<%= f.submit %>
<% end %>
zh:
activerecord:
enum:
dingtalk/app:
type:
Dingtalk::NormalApp: 普通App
Dingtalk::NewApp: NewApp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment