2011-12-12 51 views
0

我已經安裝了下列寶石: *當地的寶石*用戶註冊未在Rails的工作3個+設計+ ActiveAdmin安裝

abstract (1.0.0) 
actionmailer (3.1.1, 3.1.1.rc1, 3.0.4) 
actionpack (3.1.1, 3.1.1.rc1, 3.0.4) 
activeadmin (0.3.4) 
activemerchant (1.7.1) 
activemodel (3.1.1, 3.1.1.rc1, 3.0.4) 
activerecord (3.1.1, 3.1.1.rc1, 3.0.4) 
activeresource (3.1.1, 3.1.1.rc1, 3.0.4) 
activesupport (3.1.1, 3.1.1.rc1, 3.0.4) 
addressable (2.2.6, 2.2.4) 
ansi (1.4.1) 
archive-tar-minitar (0.5.2) 
arel (2.2.1, 2.0.9) 
aws-s3 (0.6.2) 
bcrypt-ruby (3.0.1) 
best_in_place (0.1.9) 
braintree (2.9.1) 
builder (3.0.0, 2.1.2) 
bundler (1.0.21 ruby) 
cancan (1.6.7) 
capistrano (2.5.21) 
capistrano-ext (1.2.1) 
clearance (0.10.3.2) 
cocaine (0.2.0) 
coffee-rails (3.1.1) 
coffee-script (2.2.0) 
coffee-script-source (1.1.3) 
columnize (0.3.5, 0.3.2) 
devise (1.5.1, 1.4.9) 
diesel (0.1.4) 
erubis (2.7.0, 2.6.6) 
exception_notification (2.4.0) 
execjs (1.2.9) 
factory_girl (2.0.4) 
factory_girl_rails (1.1.0) 
faraday (0.5.7) 
fastercsv (1.5.4, 1.5.3) 
formtastic (1.2.4) 
friendly_id (4.0.0.beta14) 
has_scope (0.5.1) 
heroku (2.15.1, 2.14.0) 
highline (1.6.1) 
hike (1.2.1) 
hominid (3.0.2) 
i18n (0.6.0, 0.5.0) 
inherited_resources (1.2.2) 
interactive_editor (0.0.6) 
jquery-rails (1.0.19, 1.0.18, 0.2.7) 
json (1.6.3, 1.6.1) 
kaminari (0.12.4) 
launchy (2.0.5) 
libv8 (3.3.10.4 x86-linux) 
linecache19 (0.5.12) 
mail (2.3.0, 2.2.15) 
meta_search (1.1.1) 
mime-types (1.17.2, 1.16) 
multi_json (1.0.4, 1.0.3) 
multipart-post (1.1.0) 
net-scp (1.0.4) 
net-sftp (2.0.5) 
net-ssh (2.1.4) 
net-ssh-gateway (1.0.1) 
orm_adapter (0.0.5) 
paperclip (2.4.5) 
pg (0.11.0) 
polyamorous (0.5.0) 
polyglot (0.3.3, 0.3.1) 
rack (1.3.5, 1.2.2) 
rack-cache (1.1, 1.0.3) 
rack-mount (0.8.3, 0.6.14) 
rack-ssl (1.3.2) 
rack-test (0.6.1, 0.5.7) 
rails (3.1.1, 3.1.1.rc1, 3.0.4) 
railties (3.1.1, 3.1.1.rc1, 3.0.4) 
rake (0.9.2.2, 0.9.2, 0.8.7) 
rdoc (3.11) 
RedCloth (4.2.7) 
responders (0.6.4) 
rest-client (1.6.7) 
ruby-debug-base19 (0.11.25) 
ruby-debug19 (0.11.6) 
ruby_core_source (0.1.5) 
rubyzip (0.9.5, 0.9.4) 
sass (3.1.11, 3.1.10) 
sass-rails (3.1.5, 3.1.4) 
spoon (0.0.1) 
sprockets (2.0.3) 
sqlite3 (1.3.5, 1.3.4) 
term-ansicolor (1.0.7) 
therubyracer (0.9.9) 
thor (0.14.6) 
tilt (1.3.3) 
treetop (1.4.10, 1.4.9) 
turn (0.8.3) 
tzinfo (0.3.31, 0.3.26) 
uglifier (1.1.0) 
warden (1.1.0, 1.0.6) 
xml-simple (1.0.12) 

這是我的用戶模塊

class User < ActiveRecord::Base 
    # Include default devise modules. Others available are: 
    # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and  :omniauthable 
    devise :database_authenticatable, :registerable, 
     :recoverable, :rememberable, :trackable, :validatable 

    # Setup accessible (or protected) attributes for your model 
    attr_accessible :email, :password, :password_confirmation, :remember_me 
    def has_enough_credits?(value_in_credits) 
    self.credits >= value_in_credits 
    end 
    def add_outline(outline) 
    if self.has_enough_credits?(outline.credits) 
     user_download = Download.new 
     user_download.user = self 
     user_download.outline = outline 
     user_download.save 
    else 
    return false 
    end 
    end 
end 

Initializer de Active Admin

ActiveAdmin.setup do |config| 

    config.site_title = "MyApp" 

    config.authentication_method = :authenticate_user! 

    config.current_user_method = :current_user 

    config.logout_link_path = :destroy_user_session_path 

end 

初始化程序去制定

# Use this hook to configure devise mailer, warden hooks and so forth. The first 
# four configuration values can also be set straight in your models. 
Devise.setup do |config| 
    # ==> Mailer Configuration 
    # Configure the e-mail address which will be shown in Devise::Mailer, 
    # note that it will be overwritten if you use your own mailer class with default  "from" parameter. 
    config.mailer_sender = "[email protected]" 

    # Configure the class responsible to send e-mails. 
    config.mailer = "Devise::Mailer" 

    # ==> ORM configuration 
    # Load and configure the ORM. Supports :active_record (default) and 
    # :mongoid (bson_ext recommended) by default. Other ORMs may be 
    # available as additional gems. 
    require 'devise/orm/active_record' 

    # ==> Configuration for any authentication mechanism 
    # Configure which keys are used when authenticating a user. The default is 
    # just :email. You can configure it to use [:username, :subdomain], so for 
    # authenticating a user, both parameters are required. Remember that those 
    # parameters are used only when authenticating and not when retrieving from 
    # session. If you need permissions, you should implement that in a before filter. 
    # You can also supply a hash where the value is a boolean determining whether 
    # or not authentication should be aborted when the value is not present. 
    config.authentication_keys = [ :email ] 

    # Configure which authentication keys should be case-insensitive. 
    # These keys will be downcased upon creating or modifying a user and when used 
    # to authenticate or find a user. Default is :email. 
    config.case_insensitive_keys = [ :email ] 

    # Configure which authentication keys should have whitespace stripped. 
    # These keys will have whitespace before and after removed upon creating or 
    # modifying a user and when used to authenticate or find a user. Default is :email. 
    config.strip_whitespace_keys = [ :email ] 

    # ==> Configuration for :database_authenticatable 
    # For bcrypt, this is the cost for hashing the password and defaults to 10. If 
    # using other encryptors, it sets how many times you want the password re-encrypted. 
    # 
    # Limiting the stretches to just one in testing will increase the performance of 
    # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use 
    # a value less than 10 in other environments. 
    config.stretches = Rails.env.test? ? 1 : 10 

    # Defines which key will be used when confirming an account 
    config.confirmation_keys = [ :email ] 

    # ==> Configuration for :rememberable 
    # The time the user will be remembered without asking for credentials again. 
    config.remember_for = 2.weeks 

    # If true, a valid remember token can be re-used between multiple browsers. 
    config.remember_across_browsers = true 

    # If true, extends the user's remember period when remembered via cookie. 
    config.extend_remember_period = true 

    # If true, uses the password salt as remember token. This should be turned 
    # to false if you are not using database authenticatable. 
    config.use_salt_as_remember_token = true 

    # ==> Configuration for :validatable 
    # Range for password length. Default is 6..128. 
    config.password_length = 6..128 

    # Email regex used to validate email formats. It simply asserts that 
    # an one (and only one) @ exists in the given string. This is mainly 
    # to give user feedback and not to assert the e-mail validity. 
    config.email_regexp = /\A[^@][email protected][^@]+\z/ 

    # ==> Configuration for :timeoutable 
    # The time you want to timeout the user session without activity. After this 
    # time the user will be asked for credentials again. Default is 30 minutes. 
    config.timeout_in = 30.minutes 

    # ==> Configuration for :lockable 
    # Defines which strategy will be used to lock an account. 
    # :failed_attempts = Locks an account after a number of failed attempts to sign in. 
    # :none   = No lock strategy. You should handle locking by yourself. 
    config.lock_strategy = :failed_attempts 

    # Defines which key will be used when locking and unlocking an account 
    config.unlock_keys = [ :email ] 

    # Defines which strategy will be used to unlock an account. 
    # :email = Sends an unlock link to the user email 
    # :time = Re-enables login after a certain amount of time (see :unlock_in below) 
    # :both = Enables both strategies 
    # :none = No unlock strategy. You should handle unlocking by yourself. 
    config.unlock_strategy = :both 

    # Number of authentication tries before locking an account if lock_strategy 
    # is failed attempts. 
    config.maximum_attempts = 20 

    # Time interval to unlock the account if :time is enabled as unlock_strategy. 
    config.unlock_in = 10.minutes 

    # ==> Configuration for :recoverable 
    # 
    # Defines which key will be used when recovering the password for an account 
    config.reset_password_keys = [ :email ] 

    # Time interval you can reset your password with a reset password key. 
    # Don't put a too small interval or your users won't have the time to 
    # change their passwords. 
    config.reset_password_within = 2.hours 

    # ==> Configuration for :encryptable 
    # Allow you to use another encryption algorithm besides bcrypt (default). You can use 
    # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, 
    # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) 
    # and :restful_authentication_sha1 (then you should set stretches to 10, and copy 
    # REST_AUTH_SITE_KEY to pepper) 
    config.encryptor = :sha512 

    # ==> Configuration for :token_authenticatable 
    # Defines name of the authentication token params key 
    config.token_authentication_key = :auth_token 

    # The default HTTP method used to sign out a resource. Default is :delete. 
    config.sign_out_via = :delete 

end 

服務器日誌時,我提交了報名表:

Started POST "/admin" for 127.0.0.1 at 2011-12-12 11:25:52 -0200 
    Processing by Admin::DashboardController#index as HTML 
    Parameters: {"utf8"=>"✓",  "authenticity_token"=>"d0VNThc0pgYSYErb4mkP2AClbNNOYWb0qdD5H/IDgnk=", "user"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"} 
Completed in 8ms 


Started GET "/admin/login" for 127.0.0.1 at 2011-12-12 11:25:52 -0200 
    Processing by ActiveAdmin::Devise::SessionsController#new as HTML 
Rendered devise/shared/_links.erb (0.8ms) 
Rendered /home/matis/.rvm/gems/ruby-1.9.2-p290/gems/activeadmin- 0.3.4/app/views/active_admin/devise/sessions/new.html.erb within  layouts/active_admin_logged_out (7.1ms) 
Completed 200 OK in 58ms (Views: 28.1ms | ActiveRecord: 1.1ms) 


Started GET "/assets/active_admin.css?body=1" for 127.0.0.1 at 2011-12-12 11:25:52 -0200 
Served asset /active_admin.css - 304 Not Modified (1ms) 


Started GET "/assets/active_admin/vendor.js?body=1" for 127.0.0.1 at 2011-12-12 11:25:52  -0200 
Served asset /active_admin/vendor.js - 304 Not Modified (0ms) 


Started GET "/assets/active_admin/base.js?body=1" for 127.0.0.1 at 2011-12-12 11:25:52 - 0200 
Served asset /active_admin/base.js - 304 Not Modified (0ms) 


Started GET "/assets/active_admin.js?body=1" for 127.0.0.1 at 2011-12-12 11:25:52 -0200 
Served asset /active_admin.js - 304 Not Modified (0ms) 


Started GET "/assets/active_admin/datepicker/datepicker-nipple.png" for 127.0.0.1 at 2011-12-12 11:25:52 -0200 

擔任資產/active_admin/datepicker/datepicker-nipple.png - 304未修改(0ms)

的config/routes.rb中

MyApp::Application.routes.draw do 

    devise_for :users, ActiveAdmin::Devise.config 

    ActiveAdmin.routes(self) 
    match "index" => "site#index" 
    match "search" => "site#search" 
    root :to => 'site#index' 
end 

其他詳情: 佈局似乎並不被顯示在註冊頁面確定,但形式正確地呈現,用正確的方法和正確的網址,用耙路線檢查路線,一切似乎都很好。提交表單的結果是,它將我帶到登錄頁面而不做任何事情,不創建用戶或顯示任何消息。

任何人有任何想法爲什麼會發生這種情況?

回答

0

我有註銷功能這個問題。需要確保我在包含註銷按鈕的頁面上包含了jquery和jquery ujs。我想你可以通過get來配置註銷:get,但我發現最好的解決方案是確保我的腳本按照他們應該的方式加載。 Firebug給我留下了深刻的印象。