app/models/adminpanel/user.rb in adminpanel-1.2.9 vs app/models/adminpanel/user.rb in adminpanel-1.2.10

- old
+ new

@@ -1,10 +1,14 @@ module Adminpanel class User < ActiveRecord::Base - attr_accessible :email, :name, :password, :password_confirmation + attr_accessible :email, :name, :password, :password_confirmation, :group_id has_secure_password + belongs_to :group + #group validation + validates_presence_of :group_id + #name validations validates_presence_of :name validates_length_of :name, :maximum => 25 #password validations @@ -28,13 +32,52 @@ roles.any? { |r| r.name.underscore.to_sym == role_sym } end def self.form_attributes [ - {"name" => {"type" => "text_field", "name" => "Nombre", 'label' => "Nombre", "placeholder" => "Nombre"}}, - {"email" => {"type" => "text_field", "name" => "Correo", 'label' => 'Correo', 'placeholder' => 'Correo'}}, - {"password" => {"type" => "password_field", "name" => "Contrasena", 'label' => I18n.t('model.attributes.password'), "placeholder" => I18n.t('model.attributes.password'), 'show' => 'false'}}, - {"password_confirmation" => {"type" => "password_field", "name" => "Confirmacion de contrasena", 'placeholder' => I18n.t('model.attributes.password_confirmation'), 'label' => I18n.t('model.attributes.password_confirmation'), 'show' => 'false'}}, + { + 'name' => { + 'type' => 'text_field', + 'name' => 'Nombre', + 'label' => 'Nombre', + 'placeholder' => 'Nombre' + } + }, + { + 'email' => { + 'type' => 'text_field', + 'name' => 'Correo', + 'label' => 'Correo', + 'placeholder' => 'Correo' + } + }, + { + 'password' => { + 'type' => 'password_field', + 'name' => 'Contrasena', + 'label' => I18n.t('model.attributes.password'), + 'placeholder' => I18n.t('model.attributes.password'), + 'show' => 'false' + } + }, + { + 'password_confirmation' => { + 'type' => 'password_field', + 'name' => 'Confirmacion de contrasena', + 'placeholder' => I18n.t('model.attributes.password_confirmation'), + 'label' => I18n.t('model.attributes.password_confirmation'), + 'show' => 'false' + } + }, + { + 'group_id' => { + 'type' => 'belongs_to', + 'model' => 'Adminpanel::Group', + 'remote_resource' => false, + 'placeholder' => I18n.t('model.attributes.group_id'), + 'label' => I18n.t('model.attributes.group_id') + } + }, ] end def self.display_name "Usuario"