2014-01-27 45 views
1

已有factory_girl_rails已安裝gem,在當地環境下運行良好,但不在Heroku。它說:Heroku上的FactoryGirl:特性未註冊

Factory not registered :user. 

任何想法或相關文件我應該發佈幫助?

source 'https://rubygems.org' 
ruby '2.0.0' 
gem 'rails', '4.0.2' 


gem 'jbuilder', '~> 1.2' 
gem 'jquery-rails' 
gem 'turbolinks' 
gem 'uglifier', '>= 1.3.0' 

# server and database stacks 
gem 'pg' 
gem 'rails_12factor', group: :production 
gem 'thin' 

# template and assets stacks 
gem 'bootstrap-sass' 
gem 'gon' 
gem 'jquery-ui-rails' 
gem 'sass-rails', '~> 4.0.0' 
gem 'slim-rails' 
gem 'coffee-rails', '~> 4.0.0' 
gem "filepicker-rails", "~> 1.0.0" 
gem 'simple_form' 

# authentication and authorization stacks 
gem 'devise' 
gem 'role_model' 

# functionality stacks 
gem 'state_machine' 
gem 'watu_table_builder', :require => 'table_builder' 

gem 'factory_girl_rails' 
gem 'faker' 

group :development do 
    gem "better_errors" 
    gem "binding_of_caller" 
    gem 'pry-rails' 
    gem 'quiet_assets' 
end 

group :development, :test do 
    gem 'coveralls', require: false 
    gem 'dotenv-rails' 
    gem 'rspec-rails' 
    gem 'guard-rspec' 
    gem 'rb-fchange', require: false 
    gem 'rb-fsevent', require: false # For Guard file detection on Mac OS X 
    gem 'rb-inotify', require: false 
    gem 'rb-readline', require: false 
end 

group :test do 
    gem 'capybara' 
    gem "codeclimate-test-reporter", require: nil 
    gem 'database_cleaner' 

    gem 'shoulda-matchers' 
    gem 'simplecov', require: false 
    gem 'terminal-notifier-guard' # OSX 10.8 
end 

group :doc do 
    gem 'sdoc', require: false 
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 ApplicationNew 
    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)' 
    config.time_zone = 'Singapore' 
    config.active_record.default_timezone = :local 
    config.filepicker_rails.api_key = ENV["FILEPICKER_API_KEY"] 

    # 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 

    config.i18n.enforce_available_locales = true 

    config.generators do |g| 
     g.stylesheets false 
     g.helper false 
     g.javascripts false 
     g.jbuilder false 
     g.view_specs false 
    end 

    config.autoload_paths += Dir[Rails.root.join('app', 'models', '{**/}')] 

    end 
end 

和production.rb

ApplicationNew::Application.configure do 
    # Settings specified here will take precedence over those in config/application.rb. 

    # Code is not reloaded between requests. 
    config.cache_classes = true 

    # Eager load code on boot. This eager loads most of Rails and 
    # your application in memory, allowing both thread web servers 
    # and those relying on copy on write to perform better. 
    # Rake tasks automatically ignore this option for performance. 
    config.eager_load = true 

    # Full error reports are disabled and caching is turned on. 
    config.consider_all_requests_local  = false 
    config.action_controller.perform_caching = true 

    # Enable Rack::Cache to put a simple HTTP cache in front of your application 
    # Add `rack-cache` to your Gemfile before enabling this. 
    # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. 
    # config.action_dispatch.rack_cache = true 

    # Disable Rails's static asset server (Apache or nginx will already do this). 
    config.serve_static_assets = false 

    # Compress JavaScripts and CSS. 
    config.assets.js_compressor = :uglifier 
    # config.assets.css_compressor = :sass 

    # Do not fallback to assets pipeline if a precompiled asset is missed. 
    config.assets.compile = false 

    # Generate digests for assets URLs. 
    config.assets.digest = true 

    # Version of your assets, change this if you want to expire all your assets. 
    config.assets.version = '1.0' 

    # Specifies the header that your server uses for sending files. 
    # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 
    # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 

    # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 
    # config.force_ssl = true 

    # Set to :debug to see everything in the log. 
    config.log_level = :info 

    # Prepend all log lines with the following tags. 
    # config.log_tags = [ :subdomain, :uuid ] 

    # Use a different logger for distributed setups. 
    # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 

    # Use a different cache store in production. 
    # config.cache_store = :mem_cache_store 

    # Enable serving of images, stylesheets, and JavaScripts from an asset server. 
    # config.action_controller.asset_host = "http://assets.example.com" 

    # Precompile additional assets. 
    # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 
    # config.assets.precompile += %w(search.js) 

    # Ignore bad email addresses and do not raise email delivery errors. 
    # Set this to true and configure the email server for immediate delivery to raise delivery errors. 
    # config.action_mailer.raise_delivery_errors = false 

    # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 
    # the I18n.default_locale when a translation can not be found). 
    config.i18n.fallbacks = true 

    # Send deprecation notices to registered listeners. 
    config.active_support.deprecation = :notify 

    # Disable automatic flushing of the log to improve performance. 
    # config.autoflush_log = false 

    # Use default logging formatter so that PID and timestamp are not suppressed. 
    config.log_formatter = ::Logger::Formatter.new 
end 
+0

這意味着,你已經嘗試與* Factory_girl *與不確定的運行測試,或尚未加載工廠'user'。確保你已經定義了工廠,工廠文件已被添加到回購索引,並提交,並且測試成功通過。只有當你的shell提交到heroku –

+0

我用它在本地創建種子數據,並且它工作正常 –

+0

你在哪裏存儲工廠? –

回答

1

這通常不是最好的辦法是在一個分期或生產環境中使用工廠女孩甚至只是種子數據庫。通常情況下,您只會在測試和開發組中包含gem,所以它甚至不會作爲您的heroku部署的一部分進行安裝。

大的博客文章爲什麼這不是一個好主意: http://robots.thoughtbot.com/factory_girl-for-seed-data