ejmm320
unread,Jan 6, 2012, 2:02:51 PM1/6/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rails_admin
Hi, i have this situation: i'm managing the CRUD operations over the
model Users through rails_admin and the problem is when somebody wants
to change some user data like: email or username and keep unchanged
the password and password_confirmation, the change over the record
fails. Because i'm working with Devise, i read the Devise wiki and i
found a solution for edit fields without changing password, it says:
if params[:user][:password].blank?
params[:user].delete(:password)
params[:user].delete(:password_confirmation)
end
So i decided to try with my rails_admin.rb to look like this:
config.model Usuario do
# Found columns:
field :nombre_usuario, :string
field :email, :string
field :password, :password
field :password_confirmation, :password
field :activo, :boolean
# Found associations:
field :roles, :has_and_belongs_to_many_association
#Custom labels
object_label_method do
:mostrar_nombre_usuario
end
# Sections:
list do; end
export do; end
show do; end
edit do; end
create do;
include_fields :password, :password_confirmation
end
update do;
exclude_fields :password, :password_confirmation
end
end
This code hide the fields in edit view, but nothing happens if i try
to update the other fields.
Could someone point me in the right direction?
Thanks in advance.