#325 open
Micah Geisel

problem with content_for_assignments rails extension

Reported by Micah Geisel | August 4th, 2009 @ 12:25 AM

after installing adva into a basic rails app, i generated the following error:

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.select

Extracted source (around line #13):

10: 
11:     = stylesheet_link_merged :base
12:     = yield :css
13:   
14:     /[if IE]
15:       = stylesheet_link_merged :ie
16:       

RAILS_ROOT: /home/micah/work/rumsey
Application Trace | Framework Trace | Full Trace

/home/micah/work/rumsey/vendor/plugins/adva_cms/lib/rails_ext/action_controller/content_for_assignments.rb:31:in `content_assignments_proc'
/home/micah/work/rumsey/app/views/layouts/application.html.haml:13:in `_run_haml_app47views47layouts47application46html46haml'

to get around this, i had to do the following to engines/adva_cms/lib/rails_ext/action_controller/content_for_assignments.rb. i dont fully understand the intent of all this, so i could only hack around it.

@@ -28,11 +28,13 @@ end
 ActionView::Renderable.module_eval do
   def content_assignments_proc_with_content_for_filters(view)
     Proc.new do |*names|
-      contents = view.controller.registered_contents.select { |id, content| content.target == names.first }
-      contents.each do |id, content|
-        # content_for always appends the new content. we might want to have
-        # more finegrained control over that.
-        view.content_for(names.first, content.render(view))
+      if view.controller.registered_contents
+        contents = view.controller.registered_contents.select { |id, content| content.target == names.first }
+        contents.each do |id, content|
+          # content_for always appends the new content. we might want to have
+          # more finegrained control over that.
+          view.content_for(names.first, content.render(view))
+        end
       end
       content_assignments_proc_without_content_for_filters(view).call(*names)
     end

i have several gems and plugins installed, and this only happens on the first load of the rails framework. if i refresh, the error does not reoccur, so i suspect its some sort of loading order issue. if it helps, these are the plugins and gems i have installed:

acts_as_list
adva_activity
adva_blog
adva_cells
adva_cms
adva_comments
adva_rbac
adva_user
asset_packager
cucumber_rails_debug
exception_notification
input_css

config.gem 'faker'
config.gem 'notahat-machinist', :lib => 'machinist', :source => 'http://gems.github.com'
config.gem 'bmabey-email_spec', :lib => 'email_spec', :source => 'http://gems.github.com'
config.gem 'cucumber', :lib => false
config.gem 'webrat', :lib => false
config.gem 'rspec-rails', :lib => false
config.gem 'rspec', :lib => false
config.gem 'giraffesoft-resource_controller', :lib => 'resource_controller', :source => 'http://gems.github.com'
config.gem 'chriseppstein-compass', :lib => 'compass', :source => 'http://gems.github.com', :version => '>=0.8.6'
config.gem 'haml', :version => '>=2.2'

what can i do to help track down the cause of this bug?

Comments and changes to this ticket

  • Marko Seppä

    Marko Seppä August 4th, 2009 @ 10:08 AM

    • State changed from “new” to “open”

    Hi Micah,

    Thanks for the report!
    Just added this to our product icebox.

    -- Marko

  • Marko Seppä

    Marko Seppä August 13th, 2009 @ 03:49 PM

    Hi Micah,

    first I thought this error might be caused by your use of haml, but after installing and overriding the default layout with haml I did not get any error.

    The method you are hacking there is for registered content, meaning you can add content to your views from controller. Like

    content_for(:sidebar, :foo, :except => { :action => :show }) { 'foo' } # registered content
    

    Problem is that I cannot reproduce the error you are having.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<p>Cutting edge cms, blog, wiki, forum ... plattform.</p>

<p>Find the code on <a href="http://github.com/svenfuchs/adva_cms/tree/master">GitHub: adva cms</a></p>

<p>Part of the business application framework <a href="http://www.advabest.org/">adva best</a>.</p>

Pages