2

我将我的 Rails 应用程序 2.0.2 更新到 2.3.5。我在管理部分使用活动脚手架。

我的代码中没有任何更改,但更新出现了问题。我有一个控制器“admin/user_controller”来管理用户。

这是控制器的代码:

    class Admin::UserController < ApplicationController

  layout 'admin'

  active_scaffold :user do |config|
    config.columns.exclude :content, :historique_content, :user_has_objet, :user_has_arme, :user_has_entrainement, :user_has_mission, :mp, :pvp, :user_salt, :tchat, :notoriete_by_pvp, :invitation
    config.list.columns = [:user_login, :user_niveau, :user_mail, :user_bloc, :user_valide, :group_id] #:user_description, :race, :group, :user_lastvisited, :user_nextaction, :user_combats_gagner, :user_combats_perdu, :user_combats_nul, :user_password, :user_salt, :user_combats, :user_experience, :user_mana, :user_vie
    config.create.link.page = true
    config.update.link.page = true
    config.create.columns.add :password, :password_confirmation
    config.update.columns.add :password, :password_confirmation
    config.create.columns.exclude :user_password, :user_salt
    config.update.columns.exclude :user_password, :user_salt
    config.list.sorting = {:user_login => 'ASC'}
    config.subform.columns = []
  end
end

这段代码没有随着更新而改变,但是当我进入这个页面时,我得到了这个错误:

    uninitialized constant Users

/Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in `load_missing_constant'
/Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing'
/Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in `const_missing'
/Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:361:in `constantize'
/Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in `each'
/Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in `constantize'
/Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/string/inflections.rb:162:in `constantize'
/Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:28:in `reverse_matches_for'
/Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:24:in `each'
/Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:24:in `reverse_matches_for'
/Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:11:in `reverse'
/Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/column.rb:117:in `autolink?'
/Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold.rb:107:in `links_for_associations'
/Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb:62:in `each'
/Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb:62:in `each'
/Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold.rb:106:in `links_for_associations'
/Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold.rb:59:in `active_scaffold'
/Users/Kiva/Documents/Projet-rpg/jeu/app/controllers/admin/user_controller.rb:11

我搜索了 2 天,但我没有找到问题,请你帮帮我。

4

3 回答 3

3

您的应用程序中的命名约定似乎有问题

它应该是:

class Admin::UsersController < ApplicationController

不是用户控制器,因为它是。也许它不会解决您的问题,但值得一试!

于 2010-01-12T17:21:54.293 回答
0

从 Rails 2.3.x 开始,您必须安装渲染组件插件:

./script/plugin install git://github.com/ewildgoose/render_component.git -r rails-2.3

请参阅此处的说明:https ://github.com/activescaffold/active_scaffold/wiki/getting-started

于 2010-06-17T05:03:12.837 回答
0

模型的定义方式似乎有问题。在使用 rake 备份任务访问数据库中的表时,我遇到了同样的问题。问题是我通过“belongs_to”在数据库中定义了一个表。我认为我不需要该表的模型,但 constantize 一直失败。引入模型解决了这个问题。

表:users_clients 模型:UsersClient

于 2011-03-25T17:31:02.530 回答