我目前有一个具有用户/和管理员枚举数的用户模型。我正在尝试进行一些设置,因此可以提供任何帮助。 1.如何设置它,以便只有管理员和当前用户可以查看和编辑他们的信息。 2.如何在只有管理员才能创建新用户的地方进行设置。 基本上,我需要用户采取什么步骤才能仅访问其信息并保护帐户。我已经附加了活动的admin / user.rb和一些我已经拥有的帖子的基本授权。
import 'babel-polyfill'
import React from 'react'
import { render } from 'react-dom'
// import Root from './containers/Root'
import { setName } from './actions'
// import createStore from './common/store/'
import { Provider } from 'react-redux'
import EquipmentMetadata from './containers/EquipmentMetadata'
// import ReduxPiece from './components/ReduxPiece'
import configureStore from './configureStore'
const store = configureStore()
window.EquipmentMetadata = {
store,
setName
}
render(
<Provider store={store}>
{/* <Root /> */}
<EquipmentMetadata />
</Provider>,
document.getElementById('equipment-metadata')
)
我已经获得了Pundit的一些基本授权。
ActiveAdmin.register User do
permit_params :email, :password, :password_confirmation, :name, :admin, :avatar, :bio, :location
scope_to :current_user
actions :all, :except => [:destroy, :new], unless: proc {current_user.admin?}
index do
column :name
column :email
column :admin
column :location
image_column :avatar, style: :thumb
actions
end
form do |f|
f.inputs do
f.input :name
f.input :email
f.input :bio
f.input :location
f.input :admin, label: "Admin"
f.input :password
f.input :password_confirmation
f.input :avatar
end
f.actions
end
filter :name
end