Ruby on rails - ActiveAttr 停止在生产服务器上工作



我创建了一个简单的模型来处理联系表单:

 class ContactForm
   include ActiveAttr::Model
  attribute :name
  attribute :email
  attribute :message
  attr_accessible :name, :email, :message
  validates_presence_of :name, :email, :message
  validates_format_of :email, :with => /^[-a-z0-9_+.]+@([-a-z0-9]+.)+[a-z0-9]    {2,4}$/i
end

它在开发环境中工作正常,但在生产服务器上给我一个错误,记录在独角兽日志中:

E, [2013-01-26T18:15:42.724973 #8940] ERROR -- : uninitialized constant ContactForm::ActiveAttr (NameError)

宝石文件

source 'https://rubygems.org'
gem 'rails', '3.2.11'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
gem 'bootstrap-sass'
gem 'font-awesome-sass-rails'
# gem 'acts_as_tree', :git => 'git://github.com/amerine/acts_as_tree.git'
gem 'closure_tree'
gem 'kaminari'
gem 'friendly_id'
gem 'slim'
gem 'gmaps4rails'
gem 'devise'
gem 'omniauth'
gem 'oauth2'
gem 'omniauth-facebook'
gem 'omniauth-twitter'
gem 'simple_form'
gem 'pg_search'
gem 'stamp'
gem 'acts-as-taggable-on', '~> 2.3.1'
gem 'rmagick'
gem 'carrierwave'
gem 'active_attr'
gem 'select2-rails'
# gem 'roo'
# 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'
  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby
  gem 'uglifier', '>= 1.0.3'
  gem 'compass-rails'
end
group :development do 
  gem "better_errors"
  gem "binding_of_caller"
  gem 'guard'
  gem 'letter_opener'
end
group :test do 
  gem 'minitest'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
gem 'unicorn'
# Deploy with Capistrano
gem 'capistrano'
# To use debugger
# gem 'debugger'
gem 'bullet', :group => :development
gem 'rack-mini-profiler'

我遇到了同样的问题,我的解决方法是在我的gemfile中指定active_attr的版本。

gem 'active_attr', '0.7.0'

我在 GitHub 上发现了一个问题,其他人在这里遇到了同样的问题。

我在开发环境中遇到了同样的问题。我 https://github.com/thomasklemm/email_form_rails 按照这个分步教程进行操作。

当我尝试在控制台中创建新消息时,我得到:

m=Message.new
NameError: uninitialized constant Message::ActiveAttr

我使用 Rails 3.2.1,active_attributes gem 版本是 0.0.1。

编辑

我的错,似乎我在安装 gem 时犯了一个错误(不是好的)

将宝石文件从 宝石"active_attributes","0.0.1"

自 宝石 'active_attr', '0.0.7'

现在它似乎有效...

相关内容

  • 没有找到相关文章

最新更新