Created
July 3, 2012 06:35
-
-
Save jhjguxin/3038090 to your computer and use it in GitHub Desktop.
attr_accessor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%- model_class = @auth_user.class -%> | |
<div class="page-header"> | |
<h1><%=t '.title', :default => t('helpers.titles.new', :model => model_class.model_name.human, | |
:default => "New #{model_class.model_name.human}") %></h1> | |
</div> | |
<%= simple_form_for([:auth,@auth_user]) do |f| %> | |
<%= f.error_notification %> | |
<div class="form-inputs"> | |
<%= f.input :username %> | |
<%= f.input :email %> | |
<!--%= f.input :confirmation_now, :as => :radio_buttons, :checked => @auth_user.confirmed? ? "true" : "false" %--> | |
<%= f.input :confirmation_now, :as => :boolean, :input_html => {:value => @auth_user.confirmed? ? true : false} %> | |
<%= f.input :password, :as => :password %> | |
<%= f.input :password_confirmation %> | |
<%= f.association :cms_roles, :as => :check_boxes, :collection => CmsRole.all(:order => 'name'), :checked => ( @auth_user.cms_roles.map(&:id) if @auth_user.cms_roles.present?) %> | |
</div> | |
<div class="form-actions"> | |
<%= f.button :submit, :class => 'btn-primary', :disable_with => 'loading...' %> | |
<%= link_to t('.cancel', :default => t("helpers.links.cancel")), | |
auth_users_path, :class => 'btn' %> | |
</div> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
class User < ActiveRecord::Base | |
attr_accessor :agree, :confirmation_now | |
validates_acceptance_of :agree, :message => I18n.t("must_be_agree") | |
#validates_acceptance_of :confirmation_now | |
attr_accessible :email, :password, :password_confirmation, | |
:remember_me, :username, :login, :agree,:cms_role_ids, | |
:permit_ids, :confirmation_now | |
before_save :if_confirmation_now | |
def if_confirmation_now | |
if self.confirmation_now.present? | |
self.skip_confirmation! if ["true","1",1,true].include? self.confirmation_now | |
else | |
self.confirmation_now = nil | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment