Devise的工作方式与Rails 4中的方式不同。我的用户模型中没有更改任何内容。它看起来像这样 -
create_table(:users) do |t|
## Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, :default => 0
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
t.timestamps
end
add_index :users, :email, :unique => true
add_index :users, :reset_password_token, :unique => true
我的路线看起来像是设计 -
devise_for :users, path: "", controllers: {
sessions: "users/session",
registrations: "users/registration",
passwords: "users/password"
}, path_names: {
sign_in: 'login',
password: 'forgot',
confirmation: 'confirm',
unlock: 'unblock',
sign_up: 'register',
sign_out: 'logout'
}
当我尝试从默认注册页面注册时,即registrations/new.html.erb
,我收到以下错误 -
用户:: RegistrationController #create
中的NoMethodError#Array的未定义方法`deep_symbolize_keys':0x007f8b33bcd750
我的注册表格看起来像这样(非常基本) -
<%= form_for(resource, :as => resource_name, :url => user_registration_path(resource_name)) do |f| %>
<fieldset>
<legend><h5 class="color1">Sign up</h5></legend>
<%= devise_error_messages! %>
<%= f.text_field :first_name, :placeholder => "Your first name", :autofocus => true %>
<%= f.text_field :last_name, :placeholder => "Your last name" %>
<%= f.text_field :email, :placeholder => "Your email address" %>
<%= f.phone_field :phone_number, :placeholder => "Your phone number (Optional)" %>
<%= f.password_field :password, :placeholder => "Your password" %>
<%= f.password_field :password_confirmation, :placeholder => "Please confirm your password" %>
<%= content_tag :button, :type => :submit, :class => "button small success" do %>
Sign up
<% end %>
</fieldset>
<% end %>
我尝试过的解决方案:
编辑:我的控制器代码如下所示 -
class Users::RegistrationController < Devise::RegistrationsController
end
application.rb
看起来像这样 -
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
module AppName
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
end
end
我错过了什么?任何帮助将非常感谢!
很抱歉这个很长的问题!
答案 0 :(得分:1)
好的,我发现了发生了什么。
正如Alex建议的那样,我注意到i18n
store_translations
方法中出现了错误。
我做了一些谷歌搜索,我遇到了这个 - https://github.com/plataformatec/devise/issues/337
正如史蒂文在那个github线程中指出的那样,报告该问题的人在config/locales
下有一些奇怪的yml,我也是如此。
我删除了yml
,它似乎工作正常!