Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6706813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:33:53+00:00 2026-05-26T07:33:53+00:00

A have a XML helper that is giving the error: NoMethodError in Admin/xml#index Showing

  • 0

A have a XML helper that is giving the error:

NoMethodError in Admin/xml#index

Showing C:/Rails/kimnew/app/views/admin/xml/index.rhtml where line #1 raised:

undefined method `name' for nil:NilClass

Extracted source (around line #1):

1: <% update_xml("preview") %>
2: 
3: 
4: <h2>Preview/publish</h2>

I have located it is the name for kids:

xmlmenu.item(:name=> "#{convert_html_entities(kidsmovies[n].name)}",  :type=>"project", :id=> kidsmovies[n].id) 

My XML helper:

def update_xml( output )
xmlmenu = Builder::XmlMarkup.new 

            l = Movielimit.new
            l.reel_limit = Photographer.where(:reel_online => true).count
            l.kids_limit = Photographer.where(:kids_online => true).count
            n = 0
    xmlcdata = Builder::XmlMarkup.new

        movies = Photographer.find(:all)
        #loop through all movies for reel..
        reelmovies = Photographer.where(:reel_online => true).order("reel_order")
        #loop through all movies for kids..
        kidsmovies = Photographer.find(:all, :order => 'kids_order ASC', :conditions => ["kids_online=?", true]) 

#write reel         
        xmlmenu.item(:name=>"reel",  :type=>"menuItem", :id=>1)     do  
            while n < movies.length && n < l.reel_limit
                xmlmenu.item(:name=> convert_html_entities(reelmovies[n].name),  :type=>"project", :id=> reelmovies[n].id)                                      
                n = n + 1
            end 
        end

        #write kids     
            xmlmenu.item(:name=>"kids",  :type=>"menuItem", :id=>9)     do  
                while n < (kidsmovies.length + 2)
                    xmlmenu.item(:name=> "#{convert_html_entities(kidsmovies[n].name)}",  :type=>"project", :id=> kidsmovies[n].id)                                     
                    n = n + 1
                end 
            end

#hardwiret textpage for the menu
        about = Textpage.find(1)
        if about.text && about.text.size >1  
            xmlmenu.item(:name=>"About", :type=>"textpage", :id=>3)
        end     

        ###2.content

            #textpages
        textpages = Textpage.find(:all)
        xmltextpages = Builder::XmlMarkup.new           
        for t in textpages

            #special hardwired case for contactpage
            if t.id ==  2 
                xmltextpages.textpage(:name => t.name, :id=> "4", :behaviour=>"permanent") do 
                    xmltextpages.text do    
                        xmltextpages.cdata!(t.text)
                     end    
                end

            #special hardwired case for aboutpage   
            elsif t.id == 1     
                if t.text && t.text.size >1  
                    xmltextpages.textpage(:name => t.name, :id=> "3") do 
                        xmltextpages.text do    
                            xmltextpages.cdata!(t.text)
                         end    
                     end
                end                                                             
            end 

        end 

        #projects/movies            
        xmlmovies = Builder::XmlMarkup.new
        for m in movies 
            xmlmovies.project(:id=> m.id, :name=> convert_html_entities(m.name)) do 
                if m.image
                    xmlmovies.img(:id=>m.id, :url=> m['image_file_name'])
                end                         
                if m.flv
                    xmlmovies.movie(:id=> m.id, :url=>m['flv_file_name'])
                end                                                                                 
                if m.quicktime
                    #xmlmovies.download(:id=>m.id, :url => m['quicktime'])
                    xmlmovies.download(:id=>m.id, :url => "photographer/quicktime/#{m.id}/#{m['quicktime_file_name']}") 
                end                 
                xmlmovies.text(m.text)                                      
            end         
        end 




content = "<?xml version='1.0' encoding='UTF-8'?>      
             <site>
               <general name='general' type='general'><imagePath>photographer/image/</imagePath><moviePath>../photographer/flv/</moviePath></general>           
               #{xmlmenu.to_xml}
               #{xmlmovies.to_xml}                     
               #{xmltextpages.to_xml}
               </site>"

            File.open("#{RAILS_ROOT}/public/xml/#{output}.xml", "w") do |f|

            f.puts ("#{content}")   

            end
# AWS::S3::S3Object.store(file, content, "bucket", :access => :public_read)

    end     

Also a problem is that the kids menuitem are generated only 4 project items, when there are 6 Photographers rows with kids_online = true. I pass the error when setting the name to whatever:

 xmlmenu.item(:name=> 'whatever'},  :type=>"project", :id=> kidsmovies[n].id)   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:33:53+00:00Added an answer on May 26, 2026 at 7:33 am

    Try to set n=0 before writing kids.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a helper class pulling a string from an XML file. That string
I have XML files in a directory that I wish to get over to
I have XML that looks something like this: <Root xmlns=http://widgetspecA.com/ns> ...any... <WidgetBox> <A/> <B/>
I have XML that looks like this: <Parameter Name=parameter name Value=parameter value /> which
I have XML that looks like this: <ROW ref=0005631 type=04 line=1 value=Australia/> <ROW ref=0005631
I have a helper method that serialises an object, which works until you try
I have an admin configuration for a custom module. I have a button that
I have few XSLT files, index stylesheet imports layout using xsl:import. VS says that
I have a xml like that: <item> <name>chuck - norris</name> </item> I can get
I have xml where some of the element values are unicode characters. Is it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.