views:

19

answers:

0

Hello everyone :) I have some problem - when i enter some custom page all is okay, but if i try to push reload buttom - rendering is fail.

so, this is log after FIRST PAGE ENTER:

    Processing WidgetsController#index (for 127.0.0.1 at 2010-07-13 23:27:26) [GET]
Rendering template within layouts/widgets
Rendering widgets/index
  Widget Load (0.0ms)   SELECT * FROM `widgets` WHERE (region = 'left_sidebar' a
nd active = 1)
  Widget Columns (0.0ms)   SHOW FIELDS FROM `widgets`
  Category Columns (0.0ms)   SHOW FIELDS FROM `categories`
Completed in 78ms (View: 62, DB: 0) | 200 OK [http://127.0.0.1/widgets]
  SQL (0.0ms)   SET NAMES 'utf8'
  SQL (0.0ms)   SET SQL_AUTO_IS_NULL=0

and this is the second page enter:

Processing WidgetsController#index (for 127.0.0.1 at 2010-07-13 23:27:35) [GET]
Rendering template within layouts/widgets
Rendering widgets/index
Completed in 0ms (View: 0, DB: 0) | 200 OK [http://127.0.0.1/widgets]

The problem is what in second time rails doesn't execute find method.

this is source from my plugin:

module EasyWidgets
  module HelpersMethods
    def content_for(region)
      widgets = Widget.find(:all, :conditions => ["region = ? and active = ?", region.to_s, true])          
      unless widgets.blank?
        render :file => File.dirname(__FILE__) + "/widgets_block.html.haml", :locals => {:widgets => widgets}
      end
    end

    def render_specific_widget(model)
      logger.info("------DEBUG-HERE------")  
      if !model.widget_class.blank? and EasyWidgets.pool.collection_class_names.include?(model.widget_class.constantize)
        widget_instance = EasyWidgets.pool.collection.find {|obj| obj.class == model.widget_class.constantize }
        widget_instance.widget_init
        render :file => widget_instance.view_file, :locals => widget_instance.locals 
      end
    end
  end
end

i include this methods in ApplicationHelper all works in first time, but does not in second.

In first time i see message "----DEBUG-HERE----", but is second - no!

this is full script: http://pastie.org/1043003