Forum: Ruby on Rails how do you trigger an xml response for "respond_to do |format|'

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D5df9fcd7ef4c3c937435d7d6adeab2a?d=identicon&s=25 Greg Hauptmann (Guest)
on 2009-02-19 07:02
(Received via mailing list)
Hi - how do you trigger an xml response for "respond_to do |format|' ?

Wondering why the following isn't working for me (i.e. triggers HTML
response)

 ------------------view ----------------
<% *remote_form_for* :bi_allocation, @bi_allocation, :url => {
:controller
=> "bi_allocation", *:action => "r_create"*} do |f| %>
  <%= f.text_field :amount, :size => 10 %>
  <%= submit_tag 'Create' %>
<% end %>

 ------------ controller ---------------------
  *def r_create*
    @bi_allocation = BiAllocation.new(params[:bi_allocation])
    respond_to do |format|
      if @bi_allocation.save
        format.html raise("*** *HITS THIS LINE* ***")
        format.xml  { render :xml => @bi_allocation, :status =>
:created,
:location => @bi_allocation}  *# Doesn't hit this line*
      else
        format.html { render :action => "xxxx" }
        format.xml  { render :xml => @bi_allocation.errors }
      end
    end
  end

thanks
80e4cb97cae5c8d745f72337d93fd8f2?d=identicon&s=25 MaD (Guest)
on 2009-02-19 08:05
(Received via mailing list)
try calling it with :format => 'xml'

<%= link_to "link_name", :controller => 'controller_name', :action =>
'action_name', :format => 'xml' %>
D5df9fcd7ef4c3c937435d7d6adeab2a?d=identicon&s=25 Greg Hauptmann (Guest)
on 2009-02-19 11:48
(Received via mailing list)
2009/2/19 MaD <mayer.dominik@gmail.com>

>
> try calling it with :format => 'xml'
>
> <%= link_to "link_name", :controller => 'controller_name', :action =>
> 'action_name', :format => 'xml' %>
>

tks - the remote_form_for method doesn't mention a ":format" parameter?
 actually the "link_to" method (which you used in your example) I see
doesn't mention this either?  Just wondering how one would have found
out
about this being an option here?

regards
Greg
This topic is locked and can not be replied to.