Rails method that accepts XML data from OAuth client application
I have a method that creates a new item in my Rails app. This method is used together with the web form. User fills the form and then this method is called.
I'm turning now my application into an Oauth enabled one. How to implement this method so that an OAuth client could call it and pr开发者_如何学Goovide all the data via XML?
Here is the method:
def create
@item = current_user.items.build(params[:item])
@item.custom_id = current_user.items.count + 1
if @item.save
flash[:success]="Item is successfully created. Wanna add more?"
else
flash[:error]="Something went wrong. Have you added a title?"
end
redirect_to pages_home_path
end
Use respond_to and respond_with to return XML based data. Here you can find more information.
精彩评论