Rails Render Helper Not Rendering -


one of helper functions render partials not rendering correctly.

    def render_contact_list       @contact_groups = contactgroup.find(:all, :conditions => ["user_id = ?", current_user.id])        @contact_groups.each |contact_group|         @contacts = contact.find(:all, :conditions => ["group_id = ? , owner_id = ?", contact_group.id, current_user.id])         render :text => "#{contact_group.name}<br />"         render(:partial => 'contacts/partials/view_contacts', :collection => @contacts, :as => :contact)       end   end 

all displays on page is

## 

when looking @ html of rendered page, looks this:

#<contactgroup:0x103090c78>#<contactgroup:0x103090b60> 

i commented out block function , still displayed above.

what doing wrong?

edit: realized ## coming @contact_groups being last value assigned on page. returning value , not rendering of code within block.

your helper function returning list @contact_groups. need return partial instead. might (rough example):

def render_contact_list   @contact_groups = contactgroup.find(:all, :conditions => ["user_id = ?", current_user.id])    text = ""   @contact_groups.each |contact_group|     @contacts = contact.find(:all, :conditions => ["group_id = ? , owner_id = ?", contact_group.id, current_user.id])       text << render :text => "#{contact_group.name}<br />"       text << render(:partial => 'contacts/partials/view_contacts', :collection => @contacts, :as => :contact)     end     text   end 

here, build string partially-rendered pieces, return string (by mentioning last). fact worked , without block coincidence; both first line of function , block evaluate same thing.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -