【问题标题】:Deploying To Heroku Application Error部署到 Heroku 应用程序错误
【发布时间】:2013-12-25 11:39:06
【问题描述】:

我向你展示你见过的最长的日志。我正在学习 Hartl 的教程,一切都很好,直到我尝试将应用程序推送到 heroku。我收到错误“应用程序错误 应用程序发生错误,无法提供您的页面。请稍后重试。 如果您是应用程序所有者,请查看您的日志以了解详细信息。"

不知道我哪里出错了。在 3 个小时的大部分时间里,我一直试图弄清楚这一点。任何帮助表示赞赏。

2013-12-08T10:22:44.588867+00:00 app[web.1]: => Booting WEBrick
2013-12-08T10:22:44.588867+00:00 app[web.1]: => Rails 4.0.1 application starting
 in production on http://0.0.0.0:46179
2013-12-08T10:22:44.588867+00:00 app[web.1]: => Run `rails server -h` for more s
tartup options
2013-12-08T10:22:44.588867+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-12-08T10:22:44.588867+00:00 app[web.1]: Exiting
2013-12-08T10:22:44.589578+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/
activemodel-4.0.1/lib/active_model/deprecated_mass_assignment_security.rb:14:in
`attr_accessible': `attr_accessible` is extracted out of Rails into a gem. Pleas
e use new recommended protection model for params(strong_parameters) or add `pro
tected_attributes` to your Gemfile to use old one. (RuntimeError)

编辑:这就是我取出 attr_accesible 时发生的情况。我现在可以在没有它的情况下在 heroku 上得到它,但我得到了这些 rspec 错误。有什么想法吗?

 ' c:\Sites\sample_app>bundle exec rspec spec/
including Capybara::DSL in the global scope is not recommended!
.F.............F......FF..FFF..

Failures:

  1) User pages signup with valid information should create a user
     Failure/Error: expect { click_button submit }.to change(User, :count).by(1)

       count should have been changed by 1, but was changed by 0
     # ./spec/requests/user_pages_spec.rb:46:in `block (4 levels) in <top (requi
red)>'

  2) User
     Failure/Error: it { should be_valid }
       expected #<User id: nil, name: nil, email: nil, created_at: nil, updated_
at: nil, password_digest: nil, password: nil> to be valid, but got errors: Passw
ord can't be blank, Password is too short (minimum is 6 characters), Name can't
be blank, Email can't be blank, Email is invalid, Password confirmation can't be
 blank
     # ./spec/models/user_spec.rb:19:in `block (2 levels) in <top (required)>'

  3) User when email address is already taken
     Failure/Error: user_with_same_email.email = @user.email.upcase
     NoMethodError:
       undefined method `upcase' for nil:NilClass
     # ./spec/models/user_spec.rb:79:in `block (3 levels) in <top (required)>'

  4) User when email format is valid should be valid
     Failure/Error: @user.should be_valid
       expected #<User id: nil, name: nil, email: "user@foo.COM", created_at: ni
l, updated_at: nil, password_digest: nil, password: nil> to be valid, but got er
rors: Password can't be blank, Password is too short (minimum is 6 characters),
Name can't be blank, Password confirmation can't be blank
     # ./spec/models/user_spec.rb:71:in `block (4 levels) in <top (required)>'
     # ./spec/models/user_spec.rb:69:in `each'
     # ./spec/models/user_spec.rb:69:in `block (3 levels) in <top (required)>'

  5) User return value of authenticate method with valid password
     Failure/Error: it { should == found_user.authenticate(@user.password) }
     NoMethodError:
       undefined method `authenticate' for nil:NilClass
     # ./spec/models/user_spec.rb:43:in `block (4 levels) in <top (required)>'

  6) User return value of authenticate method with invalid password
     Failure/Error: let(:user_for_invalid_password) { found_user.authenticate("i
nvalid") }
     NoMethodError:
       undefined method `authenticate' for nil:NilClass
     # ./spec/models/user_spec.rb:47:in `block (4 levels) in <top (required)>'
     # ./spec/models/user_spec.rb:49:in `block (4 levels) in <top (required)>'

  7) User return value of authenticate method with invalid password
     Failure/Error: let(:user_for_invalid_password) { found_user.authenticate("i
nvalid") }
     NoMethodError:
       undefined method `authenticate' for nil:NilClass
     # ./spec/models/user_spec.rb:47:in `block (4 levels) in <top (required)>'
     # ./spec/models/user_spec.rb:50:in `block (4 levels) in <top (required)>'

Finished in 0.37081 seconds
31 examples, 7 failures

Failed examples:

rspec ./spec/requests/user_pages_spec.rb:45 # User pages signup with valid infor
mation should create a user
rspec ./spec/models/user_spec.rb:19 # User
rspec ./spec/models/user_spec.rb:83 # User when email address is already taken
rspec ./spec/models/user_spec.rb:67 # User when email format is valid should be
valid
rspec ./spec/models/user_spec.rb:43 # User return value of authenticate method w
ith valid password
rspec ./spec/models/user_spec.rb:49 # User return value of authenticate method w
ith invalid password
rspec ./spec/models/user_spec.rb:50 # User return value of authenticate method w
ith invalid password'

【问题讨论】:

    标签: ruby-on-rails ruby heroku deployment ruby-on-rails-4


    【解决方案1】:

    在你跟踪错误

    `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.
    

    不要在 Rails 4 中使用 attr_accessible

    【讨论】:

    • 现在,取出 attr_accesible 让我可以启动 Heroku,但现在我在 rspec 测试中遇到错误。在我的原始帖子中查看它们。
    • 我没有看到你的spec
    • 与您的问题无关
    • 不是栈的方式
    • 那我应该提出一个全新的问题吗?我修复了一件事,但它破坏了另一件事。
    猜你喜欢
    • 2018-08-18
    • 2020-08-08
    • 2020-07-22
    • 1970-01-01
    • 2016-09-10
    • 2017-02-09
    • 1970-01-01
    • 2015-09-16
    • 1970-01-01
    相关资源
    最近更新 更多