ruby on rails - Cannot update status of table specific instance because rollback is taking place -


i have table subscription column status. in subscriptions controller have method accept_player supposed update subscription.status "confirmed!"

  def accept_player      @subscription = subscription.find(params[:subscription_id_accept_player])      @subscription.status = "confirmed!"       @subscription.save       authorize @subscription      redirect_to tournament_subscriptions_path(@subscription.tournament)   end 

unfortunately every time try trigger method, rollback seem take place:

started post "/accept_player/39" ::1 @ 2015-07-08 22:01:21 +0100   activerecord::schemamigration load (12.4ms)  select "schema_migrations".* "schema_migrations" /users/davidgeismar/code/davidgeismar/tennis-match/app/controllers/subscriptions_controller.rb:141: warning: duplicated key @ line 155 ignored: "cardtype" processing subscriptionscontroller#accept_player html   parameters: {"utf8"=>"✓", "authenticity_token"=>"aas8ophbpvpwnbbmx/svipsrm+eko63nuvilmroxkcu9hrvonjsqeuh7aly91gfi9phmusuqrqk7qhnv2m4l/a==", "subscription_id_accept_player"=>"39", "commit"=>"confirmer ce joueur", "subscription_id"=>"39"}   user load (13.3ms)  select  "users".* "users" "users"."id" = $1  order "users"."id" asc limit 1  [["id", 2]]   subscription load (11.6ms)  select  "subscriptions".* "subscriptions" "subscriptions"."id" = $1 limit 1  [["id", 39]]    (5.7ms)  begin   subscription exists (0.8ms)  select  1 one "subscriptions" ("subscriptions"."user_id" = 20 , "subscriptions"."id" != 39 , "subscriptions"."tournament_id" = 9) limit 1    (12.6ms)  rollback   tournament load (2.4ms)  select  "tournaments".* "tournaments" "tournaments"."id" = $1 limit 1  [["id", 9]]   user load (0.4ms)  select  "users".* "users" "users"."id" = $1 limit 1  [["id", 2]] redirected http://localhost:3000/tournaments/9/subscriptions completed 302 found in 246ms (activerecord: 79.7ms) 

any ideas might going wrong here ?

this code:

authorize @subscription 

is causing rollback. if you're in dev mode, comment out, reload!, , try manually add record , see if that's cause.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -