新手问题 Devise2 与 Devise3 有啥区别?

diguage · 2014年02月28日 · 最后由 ruby_sky 回复于 2014年02月28日 · 3203 次阅读

最近准备搞一下 BBS。@daqing 开发的 Rable,功能听完善。所以,准备拿这个系统来玩玩。

昨天看了看 Rabel 的 Gem,突然发现竟然使用的是 Devise2(2.2.4)。原来的项目中用的是 Devise3。所以,就bundle update升级了一下,Devsie 升级到了3.2.3版。简单测试了一下,登录没有问题。但是,注册总是报用户名、邮箱、密码不能为空(已经填写了),并且注册成功。

请问:

  1. 有升级的朋友吗?能分享一下经验吗?
  2. Devise2 与 Devise3 有啥区别?

附录

Gemfile
source 'https://rubygems.org'

gem 'rails', '3.2.16'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'

# gem 'pg'
gem 'mysql2'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # gem 'therubyracer', '~> 0.10.2', :platforms => :ruby
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
gem 'jquery-ui-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the web server
gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

group :production do
  gem 'rabel-meta', '1.5'
end

group :test, :development do
  gem 'rspec-rails', '~> 2.12.0'
  gem 'debugger'
end

group :test do
  gem 'rspec'
  gem 'shoulda-matchers', '~> 1.5.2'
  gem 'factory_girl_rails', '~> 3.5.0'
  gem 'cucumber-rails', :require => false
  gem 'database_cleaner'
  gem 'capybara', '~> 2.0.1'
  gem 'selenium-webdriver', '~> 2.37.0'
end

group :development do
  gem 'quiet_assets', '~> 1.0.1'
  gem 'awesome_print'
  gem 'better_errors'
end

gem 'haml'
gem 'devise'
gem 'cancan'
gem 'kaminari'
gem 'carrierwave', "~> 0.6.2"
gem 'carrierwave-upyun', '~> 0.1.6'
gem 'rmagick'
gem 'mime-types'
gem 'redcarpet'
gem 'coderay'
gem 'kgio'
gem 'dalli'
gem 'acts_as_list'
gem 'rails-settings-cached', '= 0.2.1'
gem 'facebox-rails', '~> 0.1.3'
gem 'default_value_for', '~> 2.0.2'
gem 'bootstrap-sass', '~> 2.3.2.0'
gem 'slim-rails', '~> 1.0.3'
gem 'simple_form', '~> 2.0.4'
gem 'foreman', '~> 0.61.0'
gem 'thin', '~> 1.5.0'
gem 'figaro'
升级前的Gemfile.lock
GEM
  remote: http://ruby.taobao.org/
  specs:
    actionmailer (3.2.16)
      actionpack (= 3.2.16)
      mail (~> 2.5.4)
    actionpack (3.2.16)
      activemodel (= 3.2.16)
      activesupport (= 3.2.16)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.4)
      rack (~> 1.4.5)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.2.1)
    activemodel (3.2.16)
      activesupport (= 3.2.16)
      builder (~> 3.0.0)
    activerecord (3.2.16)
      activemodel (= 3.2.16)
      activesupport (= 3.2.16)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.16)
      activemodel (= 3.2.16)
      activesupport (= 3.2.16)
    activesupport (3.2.16)
      i18n (~> 0.6, >= 0.6.4)
      multi_json (~> 1.0)
    acts_as_list (0.4.0)
      activerecord (>= 3.0)
    arel (3.0.3)
    atomic (1.1.15)
    awesome_print (1.2.0)
    bcrypt (3.1.7)
    bcrypt-ruby (3.1.5)
      bcrypt (>= 3.1.3)
    better_errors (1.1.0)
      coderay (>= 1.0.0)
      erubis (>= 2.6.6)
    bootstrap-sass (2.3.2.2)
      sass (~> 3.2)
    bourne (1.5.0)
      mocha (>= 0.13.2, < 0.15)
    builder (3.0.4)
    cancan (1.6.10)
    capybara (2.0.3)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      selenium-webdriver (~> 2.0)
      xpath (~> 1.0.0)
    carrierwave (0.6.2)
      activemodel (>= 3.2.0)
      activesupport (>= 3.2.0)
    carrierwave-upyun (0.1.6)
      carrierwave (>= 0.5.7)
      rest-client (>= 1.6.7)
    childprocess (0.5.1)
      ffi (~> 1.0, >= 1.0.11)
    coderay (1.1.0)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.7.0)
    columnize (0.3.6)
    cucumber (1.3.10)
      builder (>= 2.1.2)
      diff-lcs (>= 1.1.3)
      gherkin (~> 2.12)
      multi_json (>= 1.7.5, < 2.0)
      multi_test (>= 0.0.2)
    cucumber-rails (1.4.0)
      capybara (>= 1.1.2)
      cucumber (>= 1.2.0)
      nokogiri (>= 1.5.0)
      rails (>= 3.0.0)
    daemons (1.1.9)
    dalli (2.7.0)
    database_cleaner (1.2.0)
    debugger (1.6.5)
      columnize (>= 0.3.1)
      debugger-linecache (~> 1.2.0)
      debugger-ruby_core_source (~> 1.3.1)
    debugger-linecache (1.2.0)
    debugger-ruby_core_source (1.3.2)
    default_value_for (2.0.3)
    devise (3.2.3)
      bcrypt-ruby (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 3.2.6, < 5)
      thread_safe (~> 0.1)
      warden (~> 1.2.3)
    diff-lcs (1.1.3)
    erubis (2.7.0)
    eventmachine (1.0.3)
    execjs (2.0.2)
    facebox-rails (0.1.3)
      railties (~> 3.0)
      thor (~> 0.14)
    factory_girl (3.5.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (3.5.0)
      factory_girl (~> 3.5.0)
      railties (>= 3.0.0)
    ffi (1.9.3)
    figaro (0.7.0)
      bundler (~> 1.0)
      rails (>= 3, < 5)
    foreman (0.61.0)
      thor (>= 0.13.6)
    gherkin (2.12.2)
      multi_json (~> 1.3)
    haml (4.0.5)
      tilt
    hike (1.2.3)
    i18n (0.6.9)
    journey (1.0.4)
    jquery-rails (3.1.0)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    jquery-ui-rails (4.2.0)
      railties (>= 3.2.16)
    json (1.8.1)
    kaminari (0.15.1)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
    kgio (2.9.2)
    mail (2.5.4)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    metaclass (0.0.4)
    mime-types (1.25.1)
    mini_portile (0.5.2)
    mocha (0.14.0)
      metaclass (~> 0.0.1)
    multi_json (1.8.4)
    multi_test (0.0.3)
    nokogiri (1.6.1)
      mini_portile (~> 0.5.0)
    orm_adapter (0.5.0)
    pg (0.17.1)
    polyglot (0.3.4)
    puma (2.7.1)
      rack (>= 1.1, < 2.0)
    quiet_assets (1.0.2)
      railties (>= 3.1, < 5.0)
    rabel-meta (1.5)
    rack (1.4.5)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-ssl (1.3.3)
      rack
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (3.2.16)
      actionmailer (= 3.2.16)
      actionpack (= 3.2.16)
      activerecord (= 3.2.16)
      activeresource (= 3.2.16)
      activesupport (= 3.2.16)
      bundler (~> 1.0)
      railties (= 3.2.16)
    rails-settings-cached (0.2.1)
      rails (>= 3.0.0)
    railties (3.2.16)
      actionpack (= 3.2.16)
      activesupport (= 3.2.16)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.14.6, < 2.0)
    raindrops (0.13.0)
    rake (10.1.1)
    rdoc (3.12.2)
      json (~> 1.4)
    redcarpet (3.1.1)
    rest-client (1.6.7)
      mime-types (>= 1.16)
    rmagick (2.13.2)
    rspec (2.12.0)
      rspec-core (~> 2.12.0)
      rspec-expectations (~> 2.12.0)
      rspec-mocks (~> 2.12.0)
    rspec-core (2.12.2)
    rspec-expectations (2.12.1)
      diff-lcs (~> 1.1.3)
    rspec-mocks (2.12.2)
    rspec-rails (2.12.2)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-core (~> 2.12.0)
      rspec-expectations (~> 2.12.0)
      rspec-mocks (~> 2.12.0)
    rubyzip (1.0.0)
    sass (3.2.14)
    sass-rails (3.2.6)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    selenium-webdriver (2.37.0)
      childprocess (>= 0.2.5)
      multi_json (~> 1.0)
      rubyzip (~> 1.0.0)
      websocket (~> 1.0.4)
    shoulda-matchers (1.5.6)
      activesupport (>= 3.0.0)
      bourne (~> 1.3)
    simple_form (2.0.4)
      actionpack (~> 3.0)
      activemodel (~> 3.0)
    slim (1.3.9)
      temple (~> 0.6.3)
      tilt (~> 1.3, >= 1.3.3)
    slim-rails (1.0.3)
      actionpack (~> 3.0)
      activesupport (~> 3.0)
      railties (~> 3.0)
      slim (~> 1.0)
    sprockets (2.2.2)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    temple (0.6.7)
    thin (1.5.1)
      daemons (>= 1.0.9)
      eventmachine (>= 0.12.6)
      rack (>= 1.0.0)
    thor (0.18.1)
    thread_safe (0.2.0)
      atomic (>= 1.1.7, < 2)
    tilt (1.4.1)
    treetop (1.4.15)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.38)
    uglifier (2.4.0)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    unicorn (4.8.2)
      kgio (~> 2.6)
      rack
      raindrops (~> 0.7)
    warden (1.2.3)
      rack (>= 1.0)
    websocket (1.0.7)
    xpath (1.0.0)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  acts_as_list
  awesome_print
  better_errors
  bootstrap-sass (~> 2.3.2.0)
  cancan
  capybara (~> 2.0.1)
  carrierwave (~> 0.6.2)
  carrierwave-upyun (~> 0.1.6)
  coderay
  coffee-rails (~> 3.2.1)
  cucumber-rails
  dalli
  database_cleaner
  debugger
  default_value_for (~> 2.0.2)
  devise
  facebox-rails (~> 0.1.3)
  factory_girl_rails (~> 3.5.0)
  figaro
  foreman (~> 0.61.0)
  haml
  jquery-rails
  jquery-ui-rails
  kaminari
  kgio
  mime-types
  pg
  puma
  quiet_assets (~> 1.0.1)
  rabel-meta (= 1.5)
  rails (= 3.2.16)
  rails-settings-cached (= 0.2.1)
  redcarpet
  rmagick
  rspec
  rspec-rails (~> 2.12.0)
  sass-rails (~> 3.2.3)
  selenium-webdriver (~> 2.37.0)
  shoulda-matchers (~> 1.5.2)
  simple_form (~> 2.0.4)
  slim-rails (~> 1.0.3)
  thin (~> 1.5.0)
  uglifier (>= 1.0.3)
  unicorn
升级前的Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (3.2.16)
      actionpack (= 3.2.16)
      mail (~> 2.5.4)
    actionpack (3.2.16)
      activemodel (= 3.2.16)
      activesupport (= 3.2.16)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.4)
      rack (~> 1.4.5)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.2.1)
    activemodel (3.2.16)
      activesupport (= 3.2.16)
      builder (~> 3.0.0)
    activerecord (3.2.16)
      activemodel (= 3.2.16)
      activesupport (= 3.2.16)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.16)
      activemodel (= 3.2.16)
      activesupport (= 3.2.16)
    activesupport (3.2.16)
      i18n (~> 0.6, >= 0.6.4)
      multi_json (~> 1.0)
    acts_as_list (0.2.0)
      activerecord (>= 3.0)
    arel (3.0.3)
    awesome_print (1.1.0)
    bcrypt-ruby (3.0.1)
    better_errors (0.8.0)
      coderay (>= 1.0.0)
      erubis (>= 2.6.6)
    bootstrap-sass (2.3.2.0)
      sass (~> 3.2)
    bourne (1.4.0)
      mocha (~> 0.13.2)
    builder (3.0.4)
    cancan (1.6.10)
    capybara (2.0.3)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      selenium-webdriver (~> 2.0)
      xpath (~> 1.0.0)
    carrierwave (0.6.2)
      activemodel (>= 3.2.0)
      activesupport (>= 3.2.0)
    carrierwave-upyun (0.1.6)
      carrierwave (>= 0.5.7)
      rest-client (>= 1.6.7)
    childprocess (0.3.9)
      ffi (~> 1.0, >= 1.0.11)
    coderay (1.0.9)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.6.2)
    columnize (0.3.6)
    cucumber (1.3.2)
      builder (>= 2.1.2)
      diff-lcs (>= 1.1.3)
      gherkin (~> 2.12.0)
      multi_json (~> 1.3)
    cucumber-rails (1.3.1)
      capybara (>= 1.1.2)
      cucumber (>= 1.2.0)
      nokogiri (>= 1.5.0)
      rails (~> 3.0)
    daemons (1.1.9)
    dalli (2.6.3)
    database_cleaner (1.0.1)
    debugger (1.6.2)
      columnize (>= 0.3.1)
      debugger-linecache (~> 1.2.0)
      debugger-ruby_core_source (~> 1.2.3)
    debugger-linecache (1.2.0)
    debugger-ruby_core_source (1.2.3)
    default_value_for (2.0.2)
    devise (2.2.4)
      bcrypt-ruby (~> 3.0)
      orm_adapter (~> 0.1)
      railties (~> 3.1)
      warden (~> 1.2.1)
    diff-lcs (1.1.3)
    erubis (2.7.0)
    eventmachine (1.0.3)
    execjs (1.4.0)
      multi_json (~> 1.0)
    facebox-rails (0.1.3)
      railties (~> 3.0)
      thor (~> 0.14)
    factory_girl (3.5.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (3.5.0)
      factory_girl (~> 3.5.0)
      railties (>= 3.0.0)
    ffi (1.9.3)
    figaro (0.6.4)
      bundler (~> 1.0)
      rails (>= 3, < 5)
    foreman (0.61.0)
      thor (>= 0.13.6)
    gherkin (2.12.0)
      multi_json (~> 1.3)
    haml (4.0.3)
      tilt
    hike (1.2.3)
    i18n (0.6.9)
    journey (1.0.4)
    jquery-rails (2.2.1)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    jquery-ui-rails (4.0.3)
      jquery-rails
      railties (>= 3.1.0)
    json (1.8.1)
    kaminari (0.14.1)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
    kgio (2.8.0)
    mail (2.5.4)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    metaclass (0.0.1)
    mime-types (1.25.1)
    mocha (0.13.3)
      metaclass (~> 0.0.1)
    multi_json (1.8.2)
    mysql2 (0.3.11)
    nokogiri (1.5.9)
    orm_adapter (0.4.0)
    polyglot (0.3.3)
    quiet_assets (1.0.2)
      railties (>= 3.1, < 5.0)
    rabel-meta (1.5)
    rack (1.4.5)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-ssl (1.3.3)
      rack
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (3.2.16)
      actionmailer (= 3.2.16)
      actionpack (= 3.2.16)
      activerecord (= 3.2.16)
      activeresource (= 3.2.16)
      activesupport (= 3.2.16)
      bundler (~> 1.0)
      railties (= 3.2.16)
    rails-settings-cached (0.2.1)
      rails (>= 3.0.0)
    railties (3.2.16)
      actionpack (= 3.2.16)
      activesupport (= 3.2.16)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.14.6, < 2.0)
    raindrops (0.11.0)
    rake (10.1.0)
    rdoc (3.12.2)
      json (~> 1.4)
    redcarpet (2.3.0)
    rest-client (1.6.7)
      mime-types (>= 1.16)
    rmagick (2.13.2)
    rspec (2.12.0)
      rspec-core (~> 2.12.0)
      rspec-expectations (~> 2.12.0)
      rspec-mocks (~> 2.12.0)
    rspec-core (2.12.2)
    rspec-expectations (2.12.1)
      diff-lcs (~> 1.1.3)
    rspec-mocks (2.12.2)
    rspec-rails (2.12.2)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-core (~> 2.12.0)
      rspec-expectations (~> 2.12.0)
      rspec-mocks (~> 2.12.0)
    rubyzip (1.0.0)
    sass (3.2.9)
    sass-rails (3.2.6)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    selenium-webdriver (2.37.0)
      childprocess (>= 0.2.5)
      multi_json (~> 1.0)
      rubyzip (~> 1.0.0)
      websocket (~> 1.0.4)
    shoulda-matchers (1.5.6)
      activesupport (>= 3.0.0)
      bourne (~> 1.3)
    simple_form (2.0.4)
      actionpack (~> 3.0)
      activemodel (~> 3.0)
    slim (1.3.9)
      temple (~> 0.6.3)
      tilt (~> 1.3, >= 1.3.3)
    slim-rails (1.0.3)
      actionpack (~> 3.0)
      activesupport (~> 3.0)
      railties (~> 3.0)
      slim (~> 1.0)
    sprockets (2.2.2)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    temple (0.6.5)
    thin (1.5.1)
      daemons (>= 1.0.9)
      eventmachine (>= 0.12.6)
      rack (>= 1.0.0)
    thor (0.18.1)
    tilt (1.4.1)
    treetop (1.4.15)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.38)
    uglifier (2.1.1)
      execjs (>= 0.3.0)
      multi_json (~> 1.0, >= 1.0.2)
    unicorn (4.6.2)
      kgio (~> 2.6)
      rack
      raindrops (~> 0.7)
    warden (1.2.1)
      rack (>= 1.0)
    websocket (1.0.7)
    xpath (1.0.0)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  acts_as_list
  awesome_print
  better_errors
  bootstrap-sass (~> 2.3.2.0)
  cancan
  capybara (~> 2.0.1)
  carrierwave (~> 0.6.2)
  carrierwave-upyun (~> 0.1.6)
  coderay
  coffee-rails (~> 3.2.1)
  cucumber-rails
  dalli
  database_cleaner
  debugger
  default_value_for (~> 2.0.2)
  devise
  facebox-rails (~> 0.1.3)
  factory_girl_rails (~> 3.5.0)
  figaro
  foreman (~> 0.61.0)
  haml
  jquery-rails
  jquery-ui-rails
  kaminari
  kgio
  mime-types
  mysql2
  quiet_assets (~> 1.0.1)
  rabel-meta (= 1.5)
  rails (= 3.2.16)
  rails-settings-cached (= 0.2.1)
  redcarpet
  rmagick
  rspec
  rspec-rails (~> 2.12.0)
  sass-rails (~> 3.2.3)
  selenium-webdriver (~> 2.37.0)
  shoulda-matchers (~> 1.5.2)
  simple_form (~> 2.0.4)
  slim-rails (~> 1.0.3)
  thin (~> 1.5.0)
  uglifier (>= 1.0.3)
  unicorn

官方 wiki 有 upgrade from 2 的文章

有可能是 strong parameters 的原因。https://github.com/plataformatec/devise

#1 楼 @kgenHow To: Upgrade to Devise 2.2,没有找到Upgrade from 2

我在下面的页面找的:

#2 楼 @lalameat 我看了User里面的的字段声明,没有问题的,设置了attr_accessible

我见到 devise 都是自动绕路的,O(∩_∩)O~

token_authenticatable 已经移除了。

#6 楼 @ruby_sky 这个怎么改才能在 D3 上跑起来?能详细说明一下吗?

需要 登录 后方可回复, 如果你还没有账号请 注册新账号