Hello there,
I have a TextSnippet model and a corresponding controller that works
perfectly fine for creating new instances via html/the browser etc.
However, when accessing it via REST/xml the "@text_snippet
TextSnippet.new(params[:text_snippet])" part below leaves an empty
@text_snippet, simply because params[:text_snippet] is nil for
format.xml requests. Not entirely sure why that is, but the params
only contain the following:
format => xml
action => create
controller => text_snippets
user_id => joerg-battermann
... no text_snippets in there?!
I am seriously wondering why... when accessing via the browser and
looking at the params value then, I also have
text_snippet => HashWithIndifferentAccess (2 element(s)) ...
which is perfectly right.
Am I missing something?
Here''s the controller''s create action part:
class TextSnippetsController < ApplicationController
# POST /users/1/text_snippets
# POST /users/1/text_snippets.xml
def create
@text_snippet = TextSnippet.new(params[:text_snippet])
respond_to do |format|
if @text_snippet.save
@user.items << @text_snippet
flash[:success] = ''TextSnippet was successfully
created.''
format.html { redirect_to user_text_snippet_url(@user,
@text_snippet) }
format.xml { render :xml => @text_snippet, :status
=> :created, :location => user_text_snippet_url(@user,
@text_snippet) }
else
format.html { render :action => "new" }
format.xml { render :xml => @text_snippet.errors, :status
=> :unprocessable_entity }
end
end
end
end
Cheers and thanks,
-J
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---