radiant / radiant

Radiant is a no-fluff, open source content management system designed for small teams.
MIT License
1.69k stars 344 forks source link

ActionView::TemplateError (undefined method `any?' for nil:NilClass) #365

Open xian7 opened 11 years ago

xian7 commented 11 years ago

Summary: Clicking on "Sinppet Files" in a fresh new project results in a 500 "Application error."

Radiant Version: 1.1.3 Database: PostgreSQL 9.2 System: FreeBSD 8.3

Details:

  1. Follow generic installation instructions to create a fresh radiant project using postgresql.
  2. Setup the DB and confirm that it is working (I can run "script/console production" and call "Page.count" and get 0 as the result).
  3. Start the server in production mode.
  4. Login to the admin interface and navigate to the "Design" section.
  5. Click on "Snippet Files".
  6. Notice that you are now looking at a 500 error page.

Here is the exception from the production log file:

ActionView::TemplateError (undefined method `any?' for nil:NilClass) on line #12 of /usr/local/lib/ruby/gems/1.8/gems/radiant-snippets-extension-1.1.1/app/views/admin/snippet_files/index.html.haml:
9:           - thead.title_header do
10:             %th.name= t('snippet')
11:     %tbody
12:       - if @snippet_files.any?
13:         - @snippet_files.each do |snippet|
14:           %tr[snippet]
15:             - render_region :tbody, :locals => {:snippet => snippet} do |tbody|

    /usr/local/lib/ruby/gems/1.8/gems/radiant-snippets-extension-1.1.1/app/views/admin/snippet_files/index.html.haml:12:in `_run_haml_47usr47local47lib47ruby47gems47146847gems47radiant45snippets45extension45146146147app47views47admin47snippet_files47index46html46haml'
    haml (3.1.8) rails/./lib/haml/helpers/action_view_mods.rb:13:in `render'
    haml (3.1.8) rails/./lib/haml/helpers/action_view_mods.rb:13:in `render'
    radiant (1.1.3) lib/radiant/resource_responses.rb:18:in `response_for'
    radiant (1.1.3) app/controllers/admin/resource_controller.rb:47:in `index'
    /usr/local/lib/ruby/gems/1.8/gems/compass-rails-1.0.3/lib/compass-rails/railties/2_3.rb:9:in `process'
    sass (3.2.6) lib/sass/./sass/plugin/rack.rb:54:in `call'

Thoughts: So, yeah... @snippet_files is nil when it is probably expected to be an empty enumeration.

saturnflyer commented 11 years ago

thanks for reporting this!

Linutux commented 11 years ago

I have the same error. production.log says:

Processing Admin::SnippetFilesController#index (for 79.235.83.126 at 2013-08-28 17:40:57) [GET]
  Parameters: {"controller"=>"admin/snippet_files", "action"=>"index"}
Rendering template within layouts/application
Rendering admin/snippet_files/index

ActionView::TemplateError (undefined method `any?' for nil:NilClass) on line #12 of /usr/local/rvm/gems/ruby-1.9.3-p448@meine-domain/gems/radiant-snippets-extension-1.1.1/app/views/admin/snippet_files/index.html.haml:
9:           - thead.title_header do
10:             %th.name= t('snippet')
11:     %tbody
12:       - if @snippet_files.any?
13:         - @snippet_files.each do |snippet|
14:           %tr[snippet]
15:             - render_region :tbody, :locals => {:snippet => snippet} do |tbody|

    /usr/local/rvm/gems/ruby-1.9.3-p448@meine-domain/gems/radiant-snippets-extension-1.1.1/app/views/admin/snippet_files/index.html.haml:12:in `_run_haml_47usr47local47rvm47gems47ruby45146946345p44864einfacher45studieren47gems47radiant45snippets45extension45146146147app47views47admin47snippet_files47index46html46haml'
    haml (3.1.8) lib/haml/helpers/action_view_mods.rb:13:in `render_with_haml'
    haml (3.1.8) lib/haml/helpers/action_view_mods.rb:13:in `render_with_haml'
    radiant (1.1.3) lib/radiant/resource_responses.rb:18:in `response_for'
    radiant (1.1.3) app/controllers/admin/resource_controller.rb:47:in `index'
    /usr/local/rvm/gems/ruby-1.9.3-p448@meine-domain/gems/compass-rails-1.0.3/lib/compass-rails/railties/2_3.rb:9:in `process_with_compass'
    sass (3.2.10) lib/sass/plugin/rack.rb:54:in `call'
    <internal:prelude>:10:in `synchronize'
    passenger (4.0.14) lib/phusion_passenger/rack/thread_handler_extension.rb:77:in `process_request'
    passenger (4.0.14) lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'
    passenger (4.0.14) lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'
    passenger (4.0.14) lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'

Rendering /var/customers/webs/rvmuser/meine-domain-de/public/500.html (500 Internal Server Error)
saturnflyer commented 11 years ago

I just pushed up a new gem which should fix this: bundle update radiant-snippets-extension

Linutux commented 11 years ago

Thanks for fixing it so quick!

I did "bundle update" but now I can't start it:

Config definition error: 'defaults.snippet.filter' is defined twice:
1. /usr/local/rvm/gems/ruby-1.9.3-p448@meine-domain/gems/radiant-snippets-extension-1.1.2/config/initializers/radiant_config.rb:2:in `block in <top (required)>'
2. /usr/local/rvm/gems/ruby-1.9.3-p448@meine-domain/gems/radiant-1.1.3/config/initializers/radiant_config.rb:10:in `block in <top (required)>'
         (LoadError)
  /usr/local/rvm/gems/ruby-1.9.3-p448@meine-domain/gems/radiant-1.1.3/app/models/radiant/config.rb:192:in `define'
[.....]

What did I wrong?

jomz commented 11 years ago

You did nothing wrong. I removed that config setting from radiant core on the master branch because it did not belong there. We should probably backport that and release 1.1.4

jomz commented 11 years ago

I just merged the commit that removes this config entry from core into the 1.1.3 branch; https://github.com/radiant/radiant/commit/204968452b6828e7ab1b4b72d10e52ae93312164

Linutux commented 11 years ago

@jomz Did you also update the gem on rubygems?

jomz commented 11 years ago

No, not yet, there's a failing spec I'd like to fix first. I'll try to release today.

jomz commented 11 years ago

Fixed and pushed. @saturnflyer could you build and release 1.1.4? This issue can be closed then.

jomz commented 11 years ago

@saturnflyer scrap that, Travis failed on the 1.x branch, investigating.

saturnflyer commented 11 years ago

While we get radiant fixed up and the specs running for a new release, I pushed up a new version of radiant-snippets-extension. Update your Gemfile to use version 1.1.3 and you should be ok.