# Params missing data for format.xml?

**URL:** <https://www.ruby-forum.com/t/params-missing-data-for-format-xml/136617>\
**Category:** Rails\
**Created:** [May 4, 2008, 3:33pm UTC](https://www.ruby-forum.com/t/params-missing-data-for-format-xml/136617 "2008-05-04T15:33:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![joergbattermann](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/edb3f5/32.png) [@joergbattermann](https://www.ruby-forum.com/u/joergbattermann)\
**Post date:** [May 4, 2008, 3:33pm UTC](https://www.ruby-forum.com/t/params-missing-data-for-format-xml/136617/1 "2008-05-04T15:33:58Z")

</div>

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
