I study rails and confuse some basics. Here is my API method:
def itunes_app_create
begin
app = Spaceship::Tunes::Application.create!(name: params[:itunes_app_name],
primary_language: "English",
version: params[:itunes_app_version],
sku: params[:itunes_app_sku],
bundle_id: params[:itunes_app_bundle_id],
team_id: params[:itunes_team_id])
render json: app.to_json, status: 200
rescue
render json: app.errors.full_messages.to_json, status: 200
end
end
My line app.errors.full_messages.to_jsonfails because I just made it from what I saw. How to return a message about what caused a method failure?
Not sure if it matters, is appnot part of my model. I just need to call this from my client application and then send the result.
As a side question, what status should I return with an error in this case?
source
share