To reply to myself, don't use the extension "xml.builder". An
addition, the capybara API now uses page.driver.source instead of
page.driver.body to retrieve the XML response. ugh.
On Aug 26, 10:28 am, Chad Albers <calb...@neomantic.com> wrote:
> Hi,
>
> Yesterday, I upgraded from 3.0.3 to 3.0.10. I've encountered a
> problem with rendering XML. Here's the situation.
>
> The app is primarily a non-RESTful API app. Controller actions should
> respond to requests with an XML response without the need to have
> an .xml at the end of the route request. For my controller actions I
> have written a builder (action_name.xml.builder) template and a
> builder layout (all_responses.xml.builder). For all the actions in
> the controller, I set the default layout to "all_responses" using the
> controller layout class method.
>
> Under this scenario, Rails performed as expected in version 3.0.3.
> I could write the following and the correct XML with layout was
> produced.
>
> def action_name
> @animal = Animal.new
> render :content_type => "application/xml" and return
> end
>
> Rails would find the builder template under the controllers view
> directory as expected. It would work as well with the following:
>
> respond_to do |format|
> format.xml{render :status => 200}
> end
>
> After upgrading to rails 3.0.10. Rendering is no longer working as
> expected. Instead, I get the following error:
>
> Missing template action_name with
> {:locale=>[:eng, :eng], :formats=>[:html], :handlers=>[:rjs, :rhtml, :erb, :rxml, :builder]}
> in view paths "/Users/me/src/app_name/app/
> views" (ActionView::MissingTemplate)
>
> In other words, Rails 3.0.10 no longer can find the template. It
> instead appears to always be searching for the html template which
> doesn't exist.
>
> As a partial fix, I have to specify literally everything. For
> example....
>
> def action_name
> render :template => "controller_name/
> action_name.xml.builder", :status => 200, :layout =>
> 'all_response.xml.builder' and return
> end
>
> But it only partially fixes the problem. If I go into the debugger,
> when I'm in this action, and I execute manually the render line
> above. I receive the correct XML response with the XML from the
> all_response.xml.builder layout. However, the actual response that
> Rails 3.0.10 delivers strips XML produced by the builder layout and
> actually wraps my action_name.xml.builder XML with a HTML doc type and
> the html tags such as html and body.
>
> In other words, despite the fact that I specify manually all the views
> and layout, it insists on producing HTML.
>
> I'm at a lose about what's going on here. I search the Rails change
> logs and couldn't find anything that seems to affect the way rendering
> works.
>
> If anyone could provide help or advice, I would greatly appreciate it.
>
> Chad
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment