我想编辑' gca_user'经过一些修改后通过ActiveAdmin建模,点击“更新”时间。按钮它应该向该用户发送电子邮件。
使用版本: 红宝石" 2.1.5" Rails 4.2.1
我该怎么做?
这是代码: 应用/管理/ gca_user.rb
ActiveAdmin.register GcaUser do
permit_params :user_name, :first_name, :middle_name, :last_name, :cell_number, :social_media_provider, :social_media_id, :created_by, :created_date, :updataed_by, :updated_date, :realm, :username, :password, :credentials, :challenges, :email, :emailverified, :verificationtoken, :status, :created, :lastupdated, :provider, :nick_name
index do
selectable_column
id_column
column :user_name
column :first_name
column :middle_name
column :last_name
column :cell_number
column :social_media_provider
column :social_media_id
column :created_by
column :created_date
column :updated_by
column :updated_date
column :realm
column :username
column :password
column :credentials
column :challenges
column :email
column :emailverified
column :verificationtoken
column :status
column :created
column :lastupdated
column :provider
column :nick_name
actions
end
filter :id
filter :user_name
filter :first_name
filter :middle_name
filter :last_name
filter :password
filter :email
filter :cell_number
filter :social_media_provider
filter :social_media_id
filter :created_at
form do |f|
f.inputs "New User" do
f.input :user_name
f.input :first_name
f.input :middle_name
f.input :last_name
f.input :cell_number
f.input :social_media_provider
f.input :social_media_id
f.input :created_by
f.input :created_date
f.input :updated_by
f.input :updated_date
f.input :realm
f.input :username
f.input :password
f.input :credentials
f.input :challenges
f.input :email
f.input :emailverified
f.input :verificationtoken
f.input :status
f.input :created
f.input :lastupdated
f.input :provider
f.input :nick_name
end
f.actions
end
end
现在跟随我的控制器:
应用程序/控制器/ gca_user_controller.rb
class GcaUsersController < InheritedResources::Base
private
def gca_user_params
params.require(:gca_user).permit(:user_name, :first_name, :middle_name, :last_name, :cell_number, :social_media_provider, :social_media_id, :created_by, :created_date, :updataed_by, :updated_date, :realm, :username, :password, :credentials, :challenges, :email, :emailverified, :verificationtoken, :status, :created, :lastupdated, :provider, :nick_name )
end
end
以下是我的db-migrate文件
-db /迁移
class CreateGcaUsers < ActiveRecord::Migration
def change
create_table :gca_users do |t|
t.column :user_name, :string
t.column :first_name, :string
t.column :middle_name, :string
t.column :last_name, :string
t.column :cell_number, :string
t.column :social_media_provider, :string
t.column :social_media_id, :string
t.column :created_by, :bigint
t.column :created_date, :datetime
t.column :updated_by, :bigint
t.column :updated_date, :datetime
t.column :realm, :string
t.column :username, :string
t.column :password, :string
t.column :credentials, :string
t.column :challenges, :string
t.column :email, :string
t.column :emailverified , :boolean
t.column :verificationtoken, :string
t.column :status, :string
t.column :created, :datetime
t.column :lastupdated, :datetime
t.column :provider, :string
t.column :nick_name, :string
end
end
end
现在请告诉我该如何完全填写上述要求?
答案 0 :(得分:7)
您可以覆盖GcaUser模型的ActiveAdmin更新操作 在&#34; app / admin / gca_user.rb&#34;
中使用以下代码ActiveAdmin.register GcaUser do
controller do
def update(options={}, &block)
# You can put your send email code over here
super do |success, failure|
block.call(success, failure) if block
failure.html { render :edit }
end
end
end
end