As it's not currently possible for me to use a json templating engine (jbuilder or rabl) as per Rails3 ActionView Template Handlers doesn't work on Production Server I'm wondering how to best change this controller action to include a custom node with as_json (or something else)
class Mobile::AndroidUsersController < SecureMobileUserController
skip_before_filter :authorize, :only => :create
respond_to :json
# POST /mobile_users
# POST /mobile_users.xml
def create
@mobile_user = AndroidUser.find_by_auth(params[:mobile_user][:auth])
unless @mobile_user
@mobile_user = AndroidUser.new(params[:mobile_user])
else
@mobile_user.attributes = params[:mobile_user]
end
respond_to do |format|
if @mobile_user.save
format.json #Add a custom token node here
else
:unprocessable_entity }
format.json { render json: @mobile_user.errors, status: :unprocessable_entity }
:unprocessable_entity }
end
end
end
end
I just need to add a custom node called token that has a value that I get from calling a method on the MobileUser class
:token => MobileUser.next_token