I'm learning rails and confused about 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 app.errors.full_messages.to_json
line fails because well, I just made that up from something I saw. How do I return a message of what caused the method to fail?
Not sure if it matters, app
is not part of my model. I just need to call this from my client app and then send back the result.
As a side question, what status should I return with the error in this case?