Моя ошибка XML:
NoMethodError in Admin/xml#index
Showing C:/Rails/asdw/app/views/admin/xml/index.rhtml where line #1 raised:
undefined method `name' for "preview":String
Extracted source (around line #1):
1: <% update_xml("preview") %>
2:
3:
4: <h2>Preview/publish</h2>
Мой контроллер:
def index
@photographer = Photographer.find(:first)
#render :layout => false
end
Мой помощник XML:
module XmlHelper
require 'builder'
def update_xml(photographer, output="preview")
xml = Builder::XmlMarkup.new
xml.photographer(:name => photographer.name) do
for group in photographer.groups
xml.group(:name => group.name) do
for project in group.projects
xml.project(:name => project.name) do
for collection in project.collections
xml.collection(:name => collection.name) do
for image in collection.images
xml.image(image.description, :url => image.image, :id => image.id)
end
end
end
end
end
end
end
end
File.open("#{rails_root}/public/xml/#{output}.xml", "w") do |f|
f.puts ("#{xml}")
end
end
end
ОБНОВЛЕНИЕ:
Использование <% update_xml(photographer, "preview") %>
:
NameError in Admin/xml#index
Showing C:/Rails/asdasd/app/views/admin/xml/index.rhtml where line #1 raised:
undefined local variable or method `photographer' for #<#<Class:0x47eb990>:0x47ea238>
НОВОЕ ОБНОВЛЕНИЕ Использование <% update_xml(@photographer, "preview") %>
:
oMethodError in Admin/xml#index
Showing C:/Rails/asdfsadf/app/views/admin/xml/index.rhtml where line #1 raised:
undefined method `groups' for #<Photographer:0x45ca2d8>
Extracted source (around line #1):
1: <% update_xml(@photographer, "preview") %>
2:
3: <h2>Preview/publish</h2>