2

コード内のすべての attr_accessible を強力なパラメーターに変更したので、Rails 4.0 で動作します。私のアプリはローカルでは正常に動作しますが、Heroku にプッシュすると、コードに attr_accessible があると不平を言います。これは私が得るエラーです:

   Running: rake assets:precompile
   rake aborted!
   `attr_accessible` is extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add `protected_attributes` to your Gemfile to use old one.
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activemodel-4.0.0/lib/active_model/deprecated_mass_assignment_security.rb:14:in `attr_accessible'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/redactor-rails-0.3.5/lib/redactor-rails/orm/active_record.rb:20:in `block in extended'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/redactor-rails-0.3.5/lib/redactor-rails/orm/active_record.rb:14:in `class_eval'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/redactor-rails-0.3.5/lib/redactor-rails/orm/active_record.rb:14:in `extended'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/redactor-rails-0.3.5/lib/redactor-rails/orm/active_record.rb:9:in `extend'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/redactor-rails-0.3.5/lib/redactor-rails/orm/active_record.rb:9:in `included'
   /tmp/build_12jc2ej0437ky/app/models/redactor_rails/asset.rb:20:in `include'
   /tmp/build_12jc2ej0437ky/app/models/redactor_rails/asset.rb:20:in `<class:Asset>'
   /tmp/build_12jc2ej0437ky/app/models/redactor_rails/asset.rb:19:in `<top (required)>'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:329:in `require_or_load'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:462:in `load_missing_constant'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:183:in `const_missing'
   /tmp/build_12jc2ej0437ky/app/models/redactor_rails/document.rb:1:in `<top (required)>'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:329:in `require_or_load'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:462:in `load_missing_constant'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:183:in `const_missing'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/redactor-rails-0.3.5/lib/redactor-rails.rb:31:in `document_model'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/redactor-rails-0.3.5/app/controller/redactor_rails/documents_controller.rb:2:in `<class:DocumentsController>'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/redactor-rails-0.3.5/app/controller/redactor_rails/documents_controller.rb:1:in `<top (required)>'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:329:in `require_or_load'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:288:in `depend_on'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:206:in `require_dependency'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:464:in `each'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:464:in `block in eager_load!'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:462:in `each'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:462:in `eager_load!'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:347:in `eager_load!'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `each'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
   /tmp/build_12jc2ej0437ky/config/environment.rb:5:in `<top (required)>'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:249:in `block in run_tasks_blocks'
   /tmp/build_12jc2ej0437ky/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.0.0/lib/sprockets/rails/task.rb:54:in `block (2 levels) in define'
   Tasks: TOP => environment
   (See full trace by running task with --trace)
 !
 !     Precompiling assets failed.
 !

 !     Push rejected, failed to compile Ruby/Rails app

To git@heroku.com:scratch-cms.git
 ! [remote rejected] master -> master (pre-receive hook declined)

何が起こっているかについてのアイデアはありますか?宝石かも?工夫かも?

4

4 に答える 4

2

Rails-4では、ActiveModel::MassAssignmentSecurityがActiveModelから外されているためです。しかし、devise は attr_accessible を使用するため、それを使用するには、ur Gemfile に次の gem を追加して、もう一度ロードしてみてください。

gem 'protected_attributes'

現在、devise は rails-4 をサポートしています。このデバイスのバージョンを試してみてください。

gem 'devise', '3.0.0.rc'

編集: 次に、このリンクを使用することをお勧めします。これにより、いくつかのアイデアが得られます。

于 2013-07-30T06:53:51.893 に答える
0

私が見るように、2つの問題があります - >

1.) Gemfile に Asset Serving を含める

# static asset serving and logging on Heroku
gem 'rails_12factor', group: :production

2.) 使用する属性をapplication_controller.rb

devise_parameter_sanitizer.for(:account_update) do |u|
        u.permit(:name, :email, :password, :current_password, :password_confirmation,
                         :avatar, :firstname, :lastname, :userbio, :country, :gender)
    end

私のApplication_Controllerを見てください->ここ

モデルでアクセス可能な Attr を削除します。

于 2013-07-30T07:06:11.653 に答える
0

同じ問題。私はこの方法で解決しました

gem 'protected_attributes'
gem 'devise'
gem 'responders',          github: 'plataformatec/responders'
gem 'inherited_resources', github: 'josevalim/inherited_resources'
gem 'ransack',             github: 'ernie/ransack',            branch: 'rails-4'
gem 'activeadmin',         github: 'gregbell/active_admin', branch: 'rails4'
gem 'formtastic',          github: 'justinfrench/formtastic'
于 2013-07-30T06:56:42.017 に答える