Greg Hauptmann
2009-Feb-19 06:01 UTC
how do you trigger an xml response for "respond_to do |format|''
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 --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
MaD
2009-Feb-19 07:04 UTC
Re: how do you trigger an xml response for "respond_to do |format|''
try calling it with :format => ''xml'' <%= link_to "link_name", :controller => ''controller_name'', :action => ''action_name'', :format => ''xml'' %> --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Greg Hauptmann
2009-Feb-19 10:48 UTC
Re: how do you trigger an xml response for "respond_to do |format|''
2009/2/19 MaD <mayer.dominik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> > 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 --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---