Quantcast

sql select rolls back trying to figure out why

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

sql select rolls back trying to figure out why

fugee ohu
When I run the select that rolls back in mysql there's no problem How can I debug this?

Started POST "/artist/14/tour/3/press_releases/new" for 127.0.0.1 at 2017-05-03 19:08:27 -0400
Processing by UserPressReleasesController#tour_create as HTML
  Parameters: {"authenticity_token"=>"J/ZFBljt2V9q+yEV78t+L9BOjEkqpWHyFx29HSPdB0+/PKX7s4bxLhzcoP4mtepmoKJ2NY4JKCIOcfhJBQAMXg==", "artist_id"=>"14", "tour_id"=>"3"}
  [1m [36mUser Load (2.0ms) [0m  [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
  [1m [36mArtist Load (1.9ms) [0m  [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
  [1m [36mTour Load (1.4ms) [0m  [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
  [1m [35m (0.6ms) [0m  [1m [35mBEGIN [0m
  [1m [35m (3.0ms) [0m  [1m [31mROLLBACK [0m

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sql select rolls back trying to figure out why

Edsil Basadre
Sorry! Your question is quite vague. What did you do? You manually run a select query but then it rollback or you did a request in which it runs the select query then it rollback? please make the question more clear and if you can provide more error details.

On Thu, 4 May 2017 at 7:37 AM, fugue ohu <[hidden email]> wrote:
When I run the select that rolls back in mysql there's no problem How can I debug this?

Started POST "/artist/14/tour/3/press_releases/new" for 127.0.0.1 at 2017-05-03 19:08:27 -0400
Processing by UserPressReleasesController#tour_create as HTML
  Parameters: {"authenticity_token"=>"J/ZFBljt2V9q+yEV78t+L9BOjEkqpWHyFx29HSPdB0+/PKX7s4bxLhzcoP4mtepmoKJ2NY4JKCIOcfhJBQAMXg==", "artist_id"=>"14", "tour_id"=>"3"}
  [1m [36mUser Load (2.0ms) [0m  [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
  [1m [36mArtist Load (1.9ms) [0m  [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
  [1m [36mTour Load (1.4ms) [0m  [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
  [1m [35m (0.6ms) [0m  [1m [35mBEGIN [0m
  [1m [35m (3.0ms) [0m  [1m [31mROLLBACK [0m

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPmpWefuuhoABzjZPX_i%2BqoTBjJ_%2BWKotPoOTURzV5_TVjAj1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sql select rolls back trying to figure out why

fugee ohu


On Wednesday, May 3, 2017 at 8:04:29 PM UTC-4, Edsil Basadre wrote:
Sorry! Your question is quite vague. What did you do? You manually run a select query but then it rollback or you did a request in which it runs the select query then it rollback? please make the question more clear and if you can provide more error details.

On Thu, 4 May 2017 at 7:37 AM, fugue ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="4DLxQwOXAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...> wrote:
When I run the select that rolls back in mysql there's no problem How can I debug this?

Started POST "/artist/14/tour/3/press_releases/new" for 127.0.0.1 at 2017-05-03 19:08:27 -0400
Processing by UserPressReleasesController#tour_create as HTML
  Parameters: {"authenticity_token"=>"J/ZFBljt2V9q+yEV78t+L9BOjEkqpWHyFx29HSPdB0+/PKX7s4bxLhzcoP4mtepmoKJ2NY4JKCIOcfhJBQAMXg==", "artist_id"=>"14", "tour_id"=>"3"}
  [1m [36mUser Load (2.0ms) [0m  [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
  [1m [36mArtist Load (1.9ms) [0m  [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
  [1m [36mTour Load (1.4ms) [0m  [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
  [1m [35m (0.6ms) [0m  [1m [35mBEGIN [0m
  [1m [35m (3.0ms) [0m  [1m [31mROLLBACK [0m

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="4DLxQwOXAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonrails-ta...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="4DLxQwOXAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/opto

As you can see the log begins with a post request and you can see the params list Of course there's an associated controller action but I don't know why the rollback

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sql select rolls back trying to figure out why

Walter Lee Davis

> On May 3, 2017, at 9:07 PM, fugee ohu <[hidden email]> wrote:
>
>
>
> On Wednesday, May 3, 2017 at 8:04:29 PM UTC-4, Edsil Basadre wrote:
> Sorry! Your question is quite vague. What did you do? You manually run a select query but then it rollback or you did a request in which it runs the select query then it rollback? please make the question more clear and if you can provide more error details.
>
> On Thu, 4 May 2017 at 7:37 AM, fugue ohu <[hidden email]> wrote:
> When I run the select that rolls back in mysql there's no problem How can I debug this?
>
> Started POST "/artist/14/tour/3/press_releases/new" for 127.0.0.1 at 2017-05-03 19:08:27 -0400
> Processing by UserPressReleasesController#tour_create as HTML
>   Parameters: {"authenticity_token"=>"J/ZFBljt2V9q+yEV78t+L9BOjEkqpWHyFx29HSPdB0+/PKX7s4bxLhzcoP4mtepmoKJ2NY4JKCIOcfhJBQAMXg==", "artist_id"=>"14", "tour_id"=>"3"}
>   [1m [36mUser Load (2.0ms) [0m  [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
>   [1m [36mArtist Load (1.9ms) [0m  [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
>   [1m [36mTour Load (1.4ms) [0m  [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
>   [1m [35m (0.6ms) [0m  [1m [35mBEGIN [0m
>   [1m [35m (3.0ms) [0m  [1m [31mROLLBACK [0m
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com.
> For more options, visit https://groups.google.com/d/opto
>
> As you can see the log begins with a post request and you can see the params list Of course there's an associated controller action but I don't know why the rollback
>

I am not clear why you are using POST to load a /new path. Those are usually done with GET. You would POST from that form to the collection (the create verb), and after that, you would GET the form for the persisted object and PATCH to it to update it. I would expect this action (creating a press release for artist 14 and tour 3) to look like this: POST /artist/14/tours/3/press_releases. It would hit the press_releases_controller.rb on the #create verb (never the #new). The fact that the method is #tour_create is surprising, since you already have a tour persisted (id 4). Any further things you might do to that tour would update it, and would go through the tours_controller.rb, hitting the #update method, not the press_releases_controller.

I'm scared to ask, but what does your routes.rb file look like?

Without changing anything else right now, inside your mis-named tour_create method, add a line that looks like this, after any line that includes @press_release.save

    Rails.logger.info @press_release.errors.inspect

That should give you a concise block of output, which may end in the human readable errors on that object in a hash syntax. See what that looks like, and if it gives you any clue about why the attempt to save rolled back.

Also, have you started and finished the Michael Hartl Rails tutorial (free to use on line at https://railstutorial.org)? This, and a lot of other questions you have asked, make me think the answer is no. Working all the way through that tutorial is a great way to familiarize yourself with the basics of Rails development, including how to debug a problem when it happens. The benefit to this is so great that we pay new hires to do it at UPenn.

Walter

> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/081DC974-FD71-4CA9-BEF2-AF53A4368D0A%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sql select rolls back trying to figure out why

fugee ohu


On Wednesday, May 3, 2017 at 9:44:06 PM UTC-4, Walter Lee Davis wrote:

> On May 3, 2017, at 9:07 PM, fugee ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="x8LqA3OcAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...> wrote:
>
>
>
> On Wednesday, May 3, 2017 at 8:04:29 PM UTC-4, Edsil Basadre wrote:
> Sorry! Your question is quite vague. What did you do? You manually run a select query but then it rollback or you did a request in which it runs the select query then it rollback? please make the question more clear and if you can provide more error details.
>
> On Thu, 4 May 2017 at 7:37 AM, fugue ohu <[hidden email]> wrote:
> When I run the select that rolls back in mysql there's no problem How can I debug this?
>
> Started POST "/artist/14/tour/3/press_releases/new" for 127.0.0.1 at 2017-05-03 19:08:27 -0400
> Processing by UserPressReleasesController#tour_create as HTML
>   Parameters: {"authenticity_token"=>"J/ZFBljt2V9q+yEV78t+L9BOjEkqpWHyFx29HSPdB0+/PKX7s4bxLhzcoP4mtepmoKJ2NY4JKCIOcfhJBQAMXg==", "artist_id"=>"14", "tour_id"=>"3"}
>   [1m [36mUser Load (2.0ms) [0m  [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
>   [1m [36mArtist Load (1.9ms) [0m  [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
>   [1m [36mTour Load (1.4ms) [0m  [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
>   [1m [35m (0.6ms) [0m  [1m [35mBEGIN [0m
>   [1m [35m (3.0ms) [0m  [1m [31mROLLBACK [0m
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/opto" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/opto&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/opto&#39;;return true;">https://groups.google.com/d/opto
>
> As you can see the log begins with a post request and you can see the params list Of course there's an associated controller action but I don't know why the rollback
>

I am not clear why you are using POST to load a /new path. Those are usually done with GET. You would POST from that form to the collection (the create verb), and after that, you would GET the form for the persisted object and PATCH to it to update it. I would expect this action (creating a press release for artist 14 and tour 3) to look like this: POST /artist/14/tours/3/press_releases. It would hit the press_releases_controller.rb on the #create verb (never the #new). The fact that the method is #tour_create is surprising, since you already have a tour persisted (id 4). Any further things you might do to that tour would update it, and would go through the tours_controller.rb, hitting the #update method, not the press_releases_controller.

I'm scared to ask, but what does your routes.rb file look like?

Without changing anything else right now, inside your mis-named tour_create method, add a line that looks like this, after any line that includes @press_release.save

    <a href="http://Rails.logger.info" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FRails.logger.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEq1W5bysGS_mui_yi9tPtoktRczg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FRails.logger.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEq1W5bysGS_mui_yi9tPtoktRczg&#39;;return true;">Rails.logger.info @press_release.errors.inspect

That should give you a concise block of output, which may end in the human readable errors on that object in a hash syntax. See what that looks like, and if it gives you any clue about why the attempt to save rolled back.

Also, have you started and finished the Michael Hartl Rails tutorial (free to use on line at <a href="https://railstutorial.org" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Frailstutorial.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHycyJCw8I6pyES5ucJMACNfAHfrg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Frailstutorial.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHycyJCw8I6pyES5ucJMACNfAHfrg&#39;;return true;">https://railstutorial.org)? This, and a lot of other questions you have asked, make me think the answer is no. Working all the way through that tutorial is a great way to familiarize yourself with the basics of Rails development, including how to debug a problem when it happens. The benefit to this is so great that we pay new hires to do it at UPenn.

Walter

> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="x8LqA3OcAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="x8LqA3OcAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


  Thanks Walter I'm calling get/new which is rendering the form for  tour but when I submit I want it to create a press_release so it gets submitted to user_press_releases#tour_create indicating the press release was created from a collection of tour dates which make up the tour In terms of has_many there's no relationship between press_release and tour Hope that helps you help me

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0577fc8f-7d55-45e2-8455-504b903a2344%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sql select rolls back trying to figure out why

fugee ohu
In reply to this post by Walter Lee Davis


On Wednesday, May 3, 2017 at 9:44:06 PM UTC-4, Walter Lee Davis wrote:

> On May 3, 2017, at 9:07 PM, fugee ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="x8LqA3OcAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...> wrote:
>
>
>
> On Wednesday, May 3, 2017 at 8:04:29 PM UTC-4, Edsil Basadre wrote:
> Sorry! Your question is quite vague. What did you do? You manually run a select query but then it rollback or you did a request in which it runs the select query then it rollback? please make the question more clear and if you can provide more error details.
>
> On Thu, 4 May 2017 at 7:37 AM, fugue ohu <[hidden email]> wrote:
> When I run the select that rolls back in mysql there's no problem How can I debug this?
>
> Started POST "/artist/14/tour/3/press_releases/new" for 127.0.0.1 at 2017-05-03 19:08:27 -0400
> Processing by UserPressReleasesController#tour_create as HTML
>   Parameters: {"authenticity_token"=>"J/ZFBljt2V9q+yEV78t+L9BOjEkqpWHyFx29HSPdB0+/PKX7s4bxLhzcoP4mtepmoKJ2NY4JKCIOcfhJBQAMXg==", "artist_id"=>"14", "tour_id"=>"3"}
>   [1m [36mUser Load (2.0ms) [0m  [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
>   [1m [36mArtist Load (1.9ms) [0m  [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
>   [1m [36mTour Load (1.4ms) [0m  [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
>   [1m [35m (0.6ms) [0m  [1m [35mBEGIN [0m
>   [1m [35m (3.0ms) [0m  [1m [31mROLLBACK [0m
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/opto" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/opto&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/opto&#39;;return true;">https://groups.google.com/d/opto
>
> As you can see the log begins with a post request and you can see the params list Of course there's an associated controller action but I don't know why the rollback
>

I am not clear why you are using POST to load a /new path. Those are usually done with GET. You would POST from that form to the collection (the create verb), and after that, you would GET the form for the persisted object and PATCH to it to update it. I would expect this action (creating a press release for artist 14 and tour 3) to look like this: POST /artist/14/tours/3/press_releases. It would hit the press_releases_controller.rb on the #create verb (never the #new). The fact that the method is #tour_create is surprising, since you already have a tour persisted (id 4). Any further things you might do to that tour would update it, and would go through the tours_controller.rb, hitting the #update method, not the press_releases_controller.

I'm scared to ask, but what does your routes.rb file look like?

Without changing anything else right now, inside your mis-named tour_create method, add a line that looks like this, after any line that includes @press_release.save

    <a href="http://Rails.logger.info" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FRails.logger.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEq1W5bysGS_mui_yi9tPtoktRczg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FRails.logger.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEq1W5bysGS_mui_yi9tPtoktRczg&#39;;return true;">Rails.logger.info @press_release.errors.inspect

That should give you a concise block of output, which may end in the human readable errors on that object in a hash syntax. See what that looks like, and if it gives you any clue about why the attempt to save rolled back.

Also, have you started and finished the Michael Hartl Rails tutorial (free to use on line at <a href="https://railstutorial.org" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Frailstutorial.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHycyJCw8I6pyES5ucJMACNfAHfrg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Frailstutorial.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHycyJCw8I6pyES5ucJMACNfAHfrg&#39;;return true;">https://railstutorial.org)? This, and a lot of other questions you have asked, make me think the answer is no. Working all the way through that tutorial is a great way to familiarize yourself with the basics of Rails development, including how to debug a problem when it happens. The benefit to this is so great that we pay new hires to do it at UPenn.

Walter

> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="x8LqA3OcAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="x8LqA3OcAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


I guess I should mention I'm calling it from the tour show page without a form, just like this
<%= link_to 'Create this press release', new_user_artist_tour_press_release_path(@artist.id, @tour.id), { method: :post } %>
That's the route to user_press_releases#tour_create

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/57b824d0-7695-4b2d-b49a-606797711d27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sql select rolls back trying to figure out why

fugee ohu
In reply to this post by Walter Lee Davis


On Wednesday, May 3, 2017 at 9:44:06 PM UTC-4, Walter Lee Davis wrote:

> On May 3, 2017, at 9:07 PM, fugee ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="x8LqA3OcAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...> wrote:
>
>
>
> On Wednesday, May 3, 2017 at 8:04:29 PM UTC-4, Edsil Basadre wrote:
> Sorry! Your question is quite vague. What did you do? You manually run a select query but then it rollback or you did a request in which it runs the select query then it rollback? please make the question more clear and if you can provide more error details.
>
> On Thu, 4 May 2017 at 7:37 AM, fugue ohu <[hidden email]> wrote:
> When I run the select that rolls back in mysql there's no problem How can I debug this?
>
> Started POST "/artist/14/tour/3/press_releases/new" for 127.0.0.1 at 2017-05-03 19:08:27 -0400
> Processing by UserPressReleasesController#tour_create as HTML
>   Parameters: {"authenticity_token"=>"J/ZFBljt2V9q+yEV78t+L9BOjEkqpWHyFx29HSPdB0+/PKX7s4bxLhzcoP4mtepmoKJ2NY4JKCIOcfhJBQAMXg==", "artist_id"=>"14", "tour_id"=>"3"}
>   [1m [36mUser Load (2.0ms) [0m  [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
>   [1m [36mArtist Load (1.9ms) [0m  [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
>   [1m [36mTour Load (1.4ms) [0m  [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
>   [1m [35m (0.6ms) [0m  [1m [35mBEGIN [0m
>   [1m [35m (3.0ms) [0m  [1m [31mROLLBACK [0m
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/opto" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/opto&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/opto&#39;;return true;">https://groups.google.com/d/opto
>
> As you can see the log begins with a post request and you can see the params list Of course there's an associated controller action but I don't know why the rollback
>

I am not clear why you are using POST to load a /new path. Those are usually done with GET. You would POST from that form to the collection (the create verb), and after that, you would GET the form for the persisted object and PATCH to it to update it. I would expect this action (creating a press release for artist 14 and tour 3) to look like this: POST /artist/14/tours/3/press_releases. It would hit the press_releases_controller.rb on the #create verb (never the #new). The fact that the method is #tour_create is surprising, since you already have a tour persisted (id 4). Any further things you might do to that tour would update it, and would go through the tours_controller.rb, hitting the #update method, not the press_releases_controller.

I'm scared to ask, but what does your routes.rb file look like?

Without changing anything else right now, inside your mis-named tour_create method, add a line that looks like this, after any line that includes @press_release.save

    <a href="http://Rails.logger.info" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FRails.logger.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEq1W5bysGS_mui_yi9tPtoktRczg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FRails.logger.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEq1W5bysGS_mui_yi9tPtoktRczg&#39;;return true;">Rails.logger.info @press_release.errors.inspect

That should give you a concise block of output, which may end in the human readable errors on that object in a hash syntax. See what that looks like, and if it gives you any clue about why the attempt to save rolled back.

Also, have you started and finished the Michael Hartl Rails tutorial (free to use on line at <a href="https://railstutorial.org" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Frailstutorial.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHycyJCw8I6pyES5ucJMACNfAHfrg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Frailstutorial.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHycyJCw8I6pyES5ucJMACNfAHfrg&#39;;return true;">https://railstutorial.org)? This, and a lot of other questions you have asked, make me think the answer is no. Working all the way through that tutorial is a great way to familiarize yourself with the basics of Rails development, including how to debug a problem when it happens. The benefit to this is so great that we pay new hires to do it at UPenn.

Walter

> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="x8LqA3OcAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="x8LqA3OcAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com. 
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


Thanks I see So in conclusion a POST has no path So if I right click a link in my browser I can copy the link url but not if I right click a submit button It has no path 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3da9bc6e-1dbf-4dd5-b655-0ece470d204c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sql select rolls back trying to figure out why

Jason Fleetwood-Boldt
In reply to this post by fugee ohu
Try ActiveRecord Query Trace

see...



I would suggest setting the level to :full or :rails like so, in case the bug comes from a Gem or Rails itself. 


ActiveRecordQueryTrace.level = :full

or 

ActiveRecordQueryTrace.level = :rails
(which is NOT the default)


Also try adjusting the lines setting to something that will show you the full trace, sometimes 25 or 100 or even 200 if your stack level is very deep. (But with 200 line stacktrace, it makes it harder to read, so you have to find the right balance)

You are looking for a ruby crash within the transaction itself, which would then cause the transaction to be rolled back. 

-Jason





On May 3, 2017, at 11:35 PM, fugee ohu <[hidden email]> wrote:



On Wednesday, May 3, 2017 at 9:44:06 PM UTC-4, Walter Lee Davis wrote:

> On May 3, 2017, at 9:07 PM, fugee ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="x8LqA3OcAAAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" class="">fuge...@...> wrote:
>
>
>
> On Wednesday, May 3, 2017 at 8:04:29 PM UTC-4, Edsil Basadre wrote:
> Sorry! Your question is quite vague. What did you do? You manually run a select query but then it rollback or you did a request in which it runs the select query then it rollback? please make the question more clear and if you can provide more error details.
>
> On Thu, 4 May 2017 at 7:37 AM, fugue ohu <[hidden email]> wrote:
> When I run the select that rolls back in mysql there's no problem How can I debug this?
>
> Started POST "/artist/14/tour/3/press_releases/new" for 127.0.0.1 at 2017-05-03 19:08:27 -0400
> Processing by UserPressReleasesController#tour_create as HTML
>   Parameters: {"authenticity_token"=>"J/ZFBljt2V9q+yEV78t+L9BOjEkqpWHyFx29HSPdB0+/PKX7s4bxLhzcoP4mtepmoKJ2NY4JKCIOcfhJBQAMXg==", "artist_id"=>"14", "tour_id"=>"3"}
>   [1m [36mUser Load (2.0ms) [0m  [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
>   [1m [36mArtist Load (1.9ms) [0m  [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
>   [1m [36mTour Load (1.4ms) [0m  [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
>   [1m [35m (0.6ms) [0m  [1m [35mBEGIN [0m
>   [1m [35m (3.0ms) [0m  [1m [31mROLLBACK [0m
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com';return true;" onclick="this.href='https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com';return true;" class="">https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/opto" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/opto';return true;" onclick="this.href='https://groups.google.com/d/opto';return true;" class="">https://groups.google.com/d/opto
>
> As you can see the log begins with a post request and you can see the params list Of course there's an associated controller action but I don't know why the rollback
>

I am not clear why you are using POST to load a /new path. Those are usually done with GET. You would POST from that form to the collection (the create verb), and after that, you would GET the form for the persisted object and PATCH to it to update it. I would expect this action (creating a press release for artist 14 and tour 3) to look like this: POST /artist/14/tours/3/press_releases. It would hit the press_releases_controller.rb on the #create verb (never the #new). The fact that the method is #tour_create is surprising, since you already have a tour persisted (id 4). Any further things you might do to that tour would update it, and would go through the tours_controller.rb, hitting the #update method, not the press_releases_controller.

I'm scared to ask, but what does your routes.rb file look like?

Without changing anything else right now, inside your mis-named tour_create method, add a line that looks like this, after any line that includes @press_release.save

    <a href="http://rails.logger.info/" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2FRails.logger.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEq1W5bysGS_mui_yi9tPtoktRczg';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2FRails.logger.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEq1W5bysGS_mui_yi9tPtoktRczg';return true;" class="">Rails.logger.info @press_release.errors.inspect

That should give you a concise block of output, which may end in the human readable errors on that object in a hash syntax. See what that looks like, and if it gives you any clue about why the attempt to save rolled back.

Also, have you started and finished the Michael Hartl Rails tutorial (free to use on line at <a href="https://railstutorial.org/" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Frailstutorial.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHycyJCw8I6pyES5ucJMACNfAHfrg';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Frailstutorial.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHycyJCw8I6pyES5ucJMACNfAHfrg';return true;" class="">https://railstutorial.org)? This, and a lot of other questions you have asked, make me think the answer is no. Working all the way through that tutorial is a great way to familiarize yourself with the basics of Rails development, including how to debug a problem when it happens. The benefit to this is so great that we pay new hires to do it at UPenn.

Walter

> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="x8LqA3OcAAAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" class="">rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="x8LqA3OcAAAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" class="">rubyonra...@googlegroups.com.
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com';return true;" onclick="this.href='https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com';return true;" class="">https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;" class="">https://groups.google.com/d/optout.


I guess I should mention I'm calling it from the tour show page without a form, just like this
<%= link_to 'Create this press release', new_user_artist_tour_press_release_path(@artist.id, @tour.id), { method: :post } %>
That's the route to user_press_releases#tour_create

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/57b824d0-7695-4b2d-b49a-606797711d27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

If you'd like to reply by encrypted email you can find my public key on jasonfleetwoodboldt.com (more about setting GPG: https://gpgtools.org

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/848EBD3F-E727-4F60-9029-A298D23BEC1B%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sql select rolls back trying to figure out why

fugee ohu


On Thursday, May 4, 2017 at 12:00:06 PM UTC-4, Jason FB wrote:
Try ActiveRecord Query Trace

see...

<a href="https://github.com/ruckus/active-record-query-trace" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fruckus%2Factive-record-query-trace\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEyK7bAez5UDZhDEGHlKAspjypIHw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fruckus%2Factive-record-query-trace\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEyK7bAez5UDZhDEGHlKAspjypIHw&#39;;return true;">https://github.com/ruckus/active-record-query-trace


I would suggest setting the level to :full or :rails like so, in case the bug comes from a Gem or Rails itself. 


ActiveRecordQueryTrace.level = :full

or 

ActiveRecordQueryTrace.level = :rails
(which is NOT the default)


Also try adjusting the lines setting to something that will show you the full trace, sometimes 25 or 100 or even 200 if your stack level is very deep. (But with 200 line stacktrace, it makes it harder to read, so you have to find the right balance)

You are looking for a ruby crash within the transaction itself, which would then cause the transaction to be rolled back. 

-Jason





On May 3, 2017, at 11:35 PM, fugee ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="LSzuKSnLAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...> wrote:



On Wednesday, May 3, 2017 at 9:44:06 PM UTC-4, Walter Lee Davis wrote:

> On May 3, 2017, at 9:07 PM, fugee ohu <[hidden email]> wrote:
>
>
>
> On Wednesday, May 3, 2017 at 8:04:29 PM UTC-4, Edsil Basadre wrote:
> Sorry! Your question is quite vague. What did you do? You manually run a select query but then it rollback or you did a request in which it runs the select query then it rollback? please make the question more clear and if you can provide more error details.
>
> On Thu, 4 May 2017 at 7:37 AM, fugue ohu <[hidden email]> wrote:
> When I run the select that rolls back in mysql there's no problem How can I debug this?
>
> Started POST "/artist/14/tour/3/press_releases/new" for 127.0.0.1 at 2017-05-03 19:08:27 -0400
> Processing by UserPressReleasesController#tour_create as HTML
>   Parameters: {"authenticity_token"=>"J/ZFBljt2V9q+yEV78t+L9BOjEkqpWHyFx29HSPdB0+/PKX7s4bxLhzcoP4mtepmoKJ2NY4JKCIOcfhJBQAMXg==", "artist_id"=>"14", "tour_id"=>"3"}
>   [1m [36mUser Load (2.0ms) [0m  [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
>   [1m [36mArtist Load (1.9ms) [0m  [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
>   [1m [36mTour Load (1.4ms) [0m  [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
>   [1m [35m (0.6ms) [0m  [1m [35mBEGIN [0m
>   [1m [35m (3.0ms) [0m  [1m [31mROLLBACK [0m
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/opto" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/opto&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/opto&#39;;return true;">https://groups.google.com/d/opto
>
> As you can see the log begins with a post request and you can see the params list Of course there's an associated controller action but I don't know why the rollback
>

I am not clear why you are using POST to load a /new path. Those are usually done with GET. You would POST from that form to the collection (the create verb), and after that, you would GET the form for the persisted object and PATCH to it to update it. I would expect this action (creating a press release for artist 14 and tour 3) to look like this: POST /artist/14/tours/3/press_releases. It would hit the press_releases_controller.rb on the #create verb (never the #new). The fact that the method is #tour_create is surprising, since you already have a tour persisted (id 4). Any further things you might do to that tour would update it, and would go through the tours_controller.rb, hitting the #update method, not the press_releases_controller.

I'm scared to ask, but what does your routes.rb file look like?

Without changing anything else right now, inside your mis-named tour_create method, add a line that looks like this, after any line that includes @press_release.save

    <a href="http://rails.logger.info/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frails.logger.info%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGx_booYk8agToseh1fLYghERZtvA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frails.logger.info%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGx_booYk8agToseh1fLYghERZtvA&#39;;return true;">Rails.logger.info @press_release.errors.inspect

That should give you a concise block of output, which may end in the human readable errors on that object in a hash syntax. See what that looks like, and if it gives you any clue about why the attempt to save rolled back.

Also, have you started and finished the Michael Hartl Rails tutorial (free to use on line at <a href="https://railstutorial.org/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Frailstutorial.org%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEPqf7xnyoKlxd7LfCSuHIekGwUng&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Frailstutorial.org%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEPqf7xnyoKlxd7LfCSuHIekGwUng&#39;;return true;">https://railstutorial.org)? This, and a lot of other questions you have asked, make me think the answer is no. Working all the way through that tutorial is a great way to familiarize yourself with the basics of Rails development, including how to debug a problem when it happens. The benefit to this is so great that we pay new hires to do it at UPenn.

Walter

> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


I guess I should mention I'm calling it from the tour show page without a form, just like this
<%= link_to 'Create this press release', new_user_artist_tour_press_release_path(@<a href="http://artist.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fartist.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF9OA5Hpes7JgBQLoWw8gm43p9qlA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fartist.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF9OA5Hpes7JgBQLoWw8gm43p9qlA&#39;;return true;">artist.id, @<a href="http://tour.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftour.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFQt6heCW2lNKx4tfxeQ4ECiPtM3w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftour.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFQt6heCW2lNKx4tfxeQ4ECiPtM3w&#39;;return true;">tour.id), { method: :post } %>
That's the route to user_press_releases#tour_create

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="LSzuKSnLAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonrails-ta...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="LSzuKSnLAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/57b824d0-7695-4b2d-b49a-606797711d27%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/57b824d0-7695-4b2d-b49a-606797711d27%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/57b824d0-7695-4b2d-b49a-606797711d27%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/57b824d0-7695-4b2d-b49a-606797711d27%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

----

Jason Fleetwood-Boldt
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="LSzuKSnLAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">te...@...
<a href="http://www.jasonfleetwoodboldt.com/writing" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.jasonfleetwoodboldt.com%2Fwriting\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEDgYb2R9Pc71odefP_iaMJ_TLgaA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.jasonfleetwoodboldt.com%2Fwriting\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEDgYb2R9Pc71odefP_iaMJ_TLgaA&#39;;return true;">http://www.jasonfleetwoodboldt.com/writing

If you'd like to reply by encrypted email you can find my public key on <a href="http://jasonfleetwoodboldt.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjasonfleetwoodboldt.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGb1ZrXS-vy-0emKzzghQyxDWw2gw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjasonfleetwoodboldt.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGb1ZrXS-vy-0emKzzghQyxDWw2gw&#39;;return true;">jasonfleetwoodboldt.com (more about setting GPG: <a href="https://gpgtools.org" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgpgtools.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHndH9tmbP6n6vEQOQUZHmsUsYe9g&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgpgtools.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHndH9tmbP6n6vEQOQUZHmsUsYe9g&#39;;return true;">https://gpgtools.org) 



Started POST "/user/press_release/tour" for 127.0.0.1 at 2017-05-04 12:17:51 -0400
  [1m [36mActiveRecord::SchemaMigration Load (29.5ms) [0m   [1m [34mSELECT `schema_migrations`.* FROM `schema_migrations` [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
Processing by UserPressReleasesController#tour_create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"FvaOuIsGnRTD0xKAoS+ZxK05Y+g5CZz2UkerbAU5a8P5fgD/kn4L8xTkrrUuytWp/4LsgXAmMue/5dNicY+rug==", "press_release"=>{"artist_id"=>"14", "tour_id"=>"3"}, "commit"=>"Create Press release"}
  [1m [36mUser Load (1.7ms) [0m   [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [36mArtist Load (1.3ms) [0m   [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [36mTour Load (6.1ms) [0m   [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [35m (0.7ms) [0m   [1m [35mBEGIN [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [35m (0.8ms) [0m   [1m [31mROLLBACK [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
Redirected to http://localhost:3000/artists/14/tours/3
Completed 302 Found in 1057ms (ActiveRecord: 51.7ms)


Started GET "/artists/14/tours/3" for 127.0.0.1 at 2017-05-04 12:17:53 -0400
Processing by UserToursController#show as HTML
  Parameters: {"artist_id"=>"14", "id"=>"3"}
  [1m [36mTour Load (1.3ms) [0m   [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [36mUser Load (1.6ms) [0m   [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [36mArtist Load (2.6ms) [0m   [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  Rendering user/tours/show.html.erb within layouts/application
  [1m [36mTourDate Load (2.1ms) [0m   [1m [34mSELECT `tour_dates`.* FROM `tour_dates` WHERE `tour_dates`.`tour_id` = 3 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  Rendered user/tours/show.html.erb within layouts/application (288.5ms)
  [1m [35m (1.5ms) [0m   [1m [34mSELECT COUNT(*) FROM `artists` WHERE `artists`.`user_id` = 2 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
Completed 200 OK in 3580ms (Views: 3537.0ms | ActiveRecord: 15.8ms)


 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f8ae30cd-bc0c-4c4c-b91a-eba17aaade37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sql select rolls back trying to figure out why

Jason Fleetwood-Boldt
 

No, no, [hidden email], you'll need to debug your own app yourself.

From the log entries you sent, I can see that you did not follow my explicit advice to set the lines setting to more than 5. 

You'll want to set the lines setting to show you the entire stacktrace, because with 5 lines only you only will see the Rails gem code, not your own code. You'l want at least as many lines of stacktrace as it takes to get to your own app's code.

Then you'll need to put a debugger (pry or byebug) just before the line of code that corresponds to the rollback. 

Then you'll want to step through your code line-by-line to figure out what is causing the exception. 

Since the rest of us on this list do not have access to your app's code, it is impossible for us to debug it for you. We are only trying to point you in the right direction to empower you to use the best tools and troubleshooting methods to set yourself up for success.

If you have specific questions about tools or methodology regarding debugging, I think people on this list will help you out. But sending stacktraces without explaining where you are stuck is probably not going to get you where you need to be.

Best of luck!
-Jason




On May 4, 2017, at 12:25 PM, fugee ohu <[hidden email]> wrote:



On Thursday, May 4, 2017 at 12:00:06 PM UTC-4, Jason FB wrote:
Try ActiveRecord Query Trace

see...

<a href="https://github.com/ruckus/active-record-query-trace" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fruckus%2Factive-record-query-trace\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEyK7bAez5UDZhDEGHlKAspjypIHw';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fruckus%2Factive-record-query-trace\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEyK7bAez5UDZhDEGHlKAspjypIHw';return true;" class="">https://github.com/ruckus/active-record-query-trace


I would suggest setting the level to :full or :rails like so, in case the bug comes from a Gem or Rails itself. 


ActiveRecordQueryTrace.level = :full

or 

ActiveRecordQueryTrace.level = :rails
(which is NOT the default)


Also try adjusting the lines setting to something that will show you the full trace, sometimes 25 or 100 or even 200 if your stack level is very deep. (But with 200 line stacktrace, it makes it harder to read, so you have to find the right balance)

You are looking for a ruby crash within the transaction itself, which would then cause the transaction to be rolled back. 

-Jason





On May 3, 2017, at 11:35 PM, fugee ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="LSzuKSnLAAAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" class="">fuge...@...> wrote:



On Wednesday, May 3, 2017 at 9:44:06 PM UTC-4, Walter Lee Davis wrote:

> On May 3, 2017, at 9:07 PM, fugee ohu <[hidden email]> wrote:
>
>
>
> On Wednesday, May 3, 2017 at 8:04:29 PM UTC-4, Edsil Basadre wrote:
> Sorry! Your question is quite vague. What did you do? You manually run a select query but then it rollback or you did a request in which it runs the select query then it rollback? please make the question more clear and if you can provide more error details.
>
> On Thu, 4 May 2017 at 7:37 AM, fugue ohu <[hidden email]> wrote:
> When I run the select that rolls back in mysql there's no problem How can I debug this?
>
> Started POST "/artist/14/tour/3/press_releases/new" for 127.0.0.1 at 2017-05-03 19:08:27 -0400
> Processing by UserPressReleasesController#tour_create as HTML
>   Parameters: {"authenticity_token"=>"J/ZFBljt2V9q+yEV78t+L9BOjEkqpWHyFx29HSPdB0+/PKX7s4bxLhzcoP4mtepmoKJ2NY4JKCIOcfhJBQAMXg==", "artist_id"=>"14", "tour_id"=>"3"}
>   [1m [36mUser Load (2.0ms) [0m  [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
>   [1m [36mArtist Load (1.9ms) [0m  [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
>   [1m [36mTour Load (1.4ms) [0m  [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
>   [1m [35m (0.6ms) [0m  [1m [35mBEGIN [0m
>   [1m [35m (3.0ms) [0m  [1m [31mROLLBACK [0m
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com';return true;" onclick="this.href='https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com';return true;" class="">https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/opto" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/opto';return true;" onclick="this.href='https://groups.google.com/d/opto';return true;" class="">https://groups.google.com/d/opto
>
> As you can see the log begins with a post request and you can see the params list Of course there's an associated controller action but I don't know why the rollback
>

I am not clear why you are using POST to load a /new path. Those are usually done with GET. You would POST from that form to the collection (the create verb), and after that, you would GET the form for the persisted object and PATCH to it to update it. I would expect this action (creating a press release for artist 14 and tour 3) to look like this: POST /artist/14/tours/3/press_releases. It would hit the press_releases_controller.rb on the #create verb (never the #new). The fact that the method is #tour_create is surprising, since you already have a tour persisted (id 4). Any further things you might do to that tour would update it, and would go through the tours_controller.rb, hitting the #update method, not the press_releases_controller.

I'm scared to ask, but what does your routes.rb file look like?

Without changing anything else right now, inside your mis-named tour_create method, add a line that looks like this, after any line that includes @press_release.save

    <a href="http://rails.logger.info/" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Frails.logger.info%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGx_booYk8agToseh1fLYghERZtvA';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Frails.logger.info%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGx_booYk8agToseh1fLYghERZtvA';return true;" class="">Rails.logger.info @press_release.errors.inspect

That should give you a concise block of output, which may end in the human readable errors on that object in a hash syntax. See what that looks like, and if it gives you any clue about why the attempt to save rolled back.

Also, have you started and finished the Michael Hartl Rails tutorial (free to use on line at <a href="https://railstutorial.org/" rel="nofollow" target="_blank" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Frailstutorial.org%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEPqf7xnyoKlxd7LfCSuHIekGwUng';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Frailstutorial.org%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEPqf7xnyoKlxd7LfCSuHIekGwUng';return true;" class="">https://railstutorial.org)? This, and a lot of other questions you have asked, make me think the answer is no. Working all the way through that tutorial is a great way to familiarize yourself with the basics of Rails development, including how to debug a problem when it happens. The benefit to this is so great that we pay new hires to do it at UPenn.

Walter

> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com';return true;" onclick="this.href='https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com';return true;" class="">https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;" class="">https://groups.google.com/d/optout.


I guess I should mention I'm calling it from the tour show page without a form, just like this
<%= link_to 'Create this press release', new_user_artist_tour_press_release_path(@<a href="http://artist.id/" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fartist.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF9OA5Hpes7JgBQLoWw8gm43p9qlA';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fartist.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF9OA5Hpes7JgBQLoWw8gm43p9qlA';return true;" class="">artist.id, @<a href="http://tour.id/" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Ftour.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFQt6heCW2lNKx4tfxeQ4ECiPtM3w';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Ftour.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFQt6heCW2lNKx4tfxeQ4ECiPtM3w';return true;" class="">tour.id), { method: :post } %>
That's the route to user_press_releases#tour_create

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="LSzuKSnLAAAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" class="">rubyonrails-ta...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="LSzuKSnLAAAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" class="">rubyonra...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/57b824d0-7695-4b2d-b49a-606797711d27%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/msgid/rubyonrails-talk/57b824d0-7695-4b2d-b49a-606797711d27%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter';return true;" onclick="this.href='https://groups.google.com/d/msgid/rubyonrails-talk/57b824d0-7695-4b2d-b49a-606797711d27%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter';return true;" class="">https://groups.google.com/d/msgid/rubyonrails-talk/57b824d0-7695-4b2d-b49a-606797711d27%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;" class="">https://groups.google.com/d/optout.

----

Jason Fleetwood-Boldt
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="LSzuKSnLAAAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" class="">te...@...
<a href="http://www.jasonfleetwoodboldt.com/writing" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.jasonfleetwoodboldt.com%2Fwriting\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEDgYb2R9Pc71odefP_iaMJ_TLgaA';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.jasonfleetwoodboldt.com%2Fwriting\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEDgYb2R9Pc71odefP_iaMJ_TLgaA';return true;" class="">http://www.jasonfleetwoodboldt.com/writing

If you'd like to reply by encrypted email you can find my public key on <a href="http://jasonfleetwoodboldt.com/" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fjasonfleetwoodboldt.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGb1ZrXS-vy-0emKzzghQyxDWw2gw';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fjasonfleetwoodboldt.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGb1ZrXS-vy-0emKzzghQyxDWw2gw';return true;" class="">jasonfleetwoodboldt.com (more about setting GPG: <a href="https://gpgtools.org/" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgpgtools.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHndH9tmbP6n6vEQOQUZHmsUsYe9g';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgpgtools.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHndH9tmbP6n6vEQOQUZHmsUsYe9g';return true;" class="">https://gpgtools.org) 



Started POST "/user/press_release/tour" for 127.0.0.1 at 2017-05-04 12:17:51 -0400
  [1m [36mActiveRecord::SchemaMigration Load (29.5ms) [0m   [1m [34mSELECT `schema_migrations`.* FROM `schema_migrations` [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
Processing by UserPressReleasesController#tour_create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"FvaOuIsGnRTD0xKAoS+ZxK05Y+g5CZz2UkerbAU5a8P5fgD/kn4L8xTkrrUuytWp/4LsgXAmMue/5dNicY+rug==", "press_release"=>{"artist_id"=>"14", "tour_id"=>"3"}, "commit"=>"Create Press release"}
  [1m [36mUser Load (1.7ms) [0m   [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [36mArtist Load (1.3ms) [0m   [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [36mTour Load (6.1ms) [0m   [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [35m (0.7ms) [0m   [1m [35mBEGIN [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [35m (0.8ms) [0m   [1m [31mROLLBACK [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
Completed 302 Found in 1057ms (ActiveRecord: 51.7ms)


Started GET "/artists/14/tours/3" for 127.0.0.1 at 2017-05-04 12:17:53 -0400
Processing by UserToursController#show as HTML
  Parameters: {"artist_id"=>"14", "id"=>"3"}
  [1m [36mTour Load (1.3ms) [0m   [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [36mUser Load (1.6ms) [0m   [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [36mArtist Load (2.6ms) [0m   [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  Rendering user/tours/show.html.erb within layouts/application
  [1m [36mTourDate Load (2.1ms) [0m   [1m [34mSELECT `tour_dates`.* FROM `tour_dates` WHERE `tour_dates`.`tour_id` = 3 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  Rendered user/tours/show.html.erb within layouts/application (288.5ms)
  [1m [35m (1.5ms) [0m   [1m [34mSELECT COUNT(*) FROM `artists` WHERE `artists`.`user_id` = 2 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
Completed 200 OK in 3580ms (Views: 3537.0ms | ActiveRecord: 15.8ms)


 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f8ae30cd-bc0c-4c4c-b91a-eba17aaade37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

If you'd like to reply by encrypted email you can find my public key on jasonfleetwoodboldt.com (more about setting GPG: https://gpgtools.org

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3D285BA1-FE82-482B-AA32-0E08DD2E0BB6%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sql select rolls back trying to figure out why

fugee ohu


On Thursday, May 4, 2017 at 4:03:03 PM UTC-4, Jason FB wrote:
 

No, no, <a href="javascript:" target="_blank" gdf-obfuscated-mailto="NTFQPGvYAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@..., you'll need to debug your own app yourself.

From the log entries you sent, I can see that you did not follow my explicit advice to set the lines setting to more than 5. 

You'll want to set the lines setting to show you the entire stacktrace, because with 5 lines only you only will see the Rails gem code, not your own code. You'l want at least as many lines of stacktrace as it takes to get to your own app's code.

Then you'll need to put a debugger (pry or byebug) just before the line of code that corresponds to the rollback. 

Then you'll want to step through your code line-by-line to figure out what is causing the exception. 

Since the rest of us on this list do not have access to your app's code, it is impossible for us to debug it for you. We are only trying to point you in the right direction to empower you to use the best tools and troubleshooting methods to set yourself up for success.

If you have specific questions about tools or methodology regarding debugging, I think people on this list will help you out. But sending stacktraces without explaining where you are stuck is probably not going to get you where you need to be.

Best of luck!
-Jason




On May 4, 2017, at 12:25 PM, fugee ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="NTFQPGvYAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...> wrote:



On Thursday, May 4, 2017 at 12:00:06 PM UTC-4, Jason FB wrote:
Try ActiveRecord Query Trace

see...

<a href="https://github.com/ruckus/active-record-query-trace" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fruckus%2Factive-record-query-trace\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEyK7bAez5UDZhDEGHlKAspjypIHw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fruckus%2Factive-record-query-trace\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEyK7bAez5UDZhDEGHlKAspjypIHw&#39;;return true;">https://github.com/ruckus/active-record-query-trace


I would suggest setting the level to :full or :rails like so, in case the bug comes from a Gem or Rails itself. 


ActiveRecordQueryTrace.level = :full

or 

ActiveRecordQueryTrace.level = :rails
(which is NOT the default)


Also try adjusting the lines setting to something that will show you the full trace, sometimes 25 or 100 or even 200 if your stack level is very deep. (But with 200 line stacktrace, it makes it harder to read, so you have to find the right balance)

You are looking for a ruby crash within the transaction itself, which would then cause the transaction to be rolled back. 

-Jason





On May 3, 2017, at 11:35 PM, fugee ohu <[hidden email]> wrote:



On Wednesday, May 3, 2017 at 9:44:06 PM UTC-4, Walter Lee Davis wrote:

> On May 3, 2017, at 9:07 PM, fugee ohu <[hidden email]> wrote:
>
>
>
> On Wednesday, May 3, 2017 at 8:04:29 PM UTC-4, Edsil Basadre wrote:
> Sorry! Your question is quite vague. What did you do? You manually run a select query but then it rollback or you did a request in which it runs the select query then it rollback? please make the question more clear and if you can provide more error details.
>
> On Thu, 4 May 2017 at 7:37 AM, fugue ohu <[hidden email]> wrote:
> When I run the select that rolls back in mysql there's no problem How can I debug this?
>
> Started POST "/artist/14/tour/3/press_releases/new" for 127.0.0.1 at 2017-05-03 19:08:27 -0400
> Processing by UserPressReleasesController#tour_create as HTML
>   Parameters: {"authenticity_token"=>"J/ZFBljt2V9q+yEV78t+L9BOjEkqpWHyFx29HSPdB0+/PKX7s4bxLhzcoP4mtepmoKJ2NY4JKCIOcfhJBQAMXg==", "artist_id"=>"14", "tour_id"=>"3"}
>   [1m [36mUser Load (2.0ms) [0m  [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
>   [1m [36mArtist Load (1.9ms) [0m  [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
>   [1m [36mTour Load (1.4ms) [0m  [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
>   [1m [35m (0.6ms) [0m  [1m [35mBEGIN [0m
>   [1m [35m (3.0ms) [0m  [1m [31mROLLBACK [0m
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/opto" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/opto&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/opto&#39;;return true;">https://groups.google.com/d/opto
>
> As you can see the log begins with a post request and you can see the params list Of course there's an associated controller action but I don't know why the rollback
>

I am not clear why you are using POST to load a /new path. Those are usually done with GET. You would POST from that form to the collection (the create verb), and after that, you would GET the form for the persisted object and PATCH to it to update it. I would expect this action (creating a press release for artist 14 and tour 3) to look like this: POST /artist/14/tours/3/press_releases. It would hit the press_releases_controller.rb on the #create verb (never the #new). The fact that the method is #tour_create is surprising, since you already have a tour persisted (id 4). Any further things you might do to that tour would update it, and would go through the tours_controller.rb, hitting the #update method, not the press_releases_controller.

I'm scared to ask, but what does your routes.rb file look like?

Without changing anything else right now, inside your mis-named tour_create method, add a line that looks like this, after any line that includes @press_release.save

    <a href="http://rails.logger.info/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frails.logger.info%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGx_booYk8agToseh1fLYghERZtvA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frails.logger.info%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGx_booYk8agToseh1fLYghERZtvA&#39;;return true;">Rails.logger.info @press_release.errors.inspect

That should give you a concise block of output, which may end in the human readable errors on that object in a hash syntax. See what that looks like, and if it gives you any clue about why the attempt to save rolled back.

Also, have you started and finished the Michael Hartl Rails tutorial (free to use on line at <a href="https://railstutorial.org/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Frailstutorial.org%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEPqf7xnyoKlxd7LfCSuHIekGwUng&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Frailstutorial.org%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEPqf7xnyoKlxd7LfCSuHIekGwUng&#39;;return true;">https://railstutorial.org)? This, and a lot of other questions you have asked, make me think the answer is no. Working all the way through that tutorial is a great way to familiarize yourself with the basics of Rails development, including how to debug a problem when it happens. The benefit to this is so great that we pay new hires to do it at UPenn.

Walter

> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/1b625052-81a0-4ed5-9ddf-a0561a2f889d%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


I guess I should mention I'm calling it from the tour show page without a form, just like this
<%= link_to 'Create this press release', new_user_artist_tour_press_release_path(@<a href="http://artist.id/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fartist.id%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFIlNQQXfk1K68-D-Z6bbymP6w7ZQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fartist.id%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFIlNQQXfk1K68-D-Z6bbymP6w7ZQ&#39;;return true;">artist.id, @<a href="http://tour.id/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftour.id%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFqwn9wcyL4qsFIlSrTzFOtANqe5A&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftour.id%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFqwn9wcyL4qsFIlSrTzFOtANqe5A&#39;;return true;">tour.id), { method: :post } %>
That's the route to user_press_releases#tour_create

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/57b824d0-7695-4b2d-b49a-606797711d27%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/57b824d0-7695-4b2d-b49a-606797711d27%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/57b824d0-7695-4b2d-b49a-606797711d27%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/57b824d0-7695-4b2d-b49a-606797711d27%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

----

Jason Fleetwood-Boldt
<a href="http://www.jasonfleetwoodboldt.com/writing" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.jasonfleetwoodboldt.com%2Fwriting\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEDgYb2R9Pc71odefP_iaMJ_TLgaA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.jasonfleetwoodboldt.com%2Fwriting\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEDgYb2R9Pc71odefP_iaMJ_TLgaA&#39;;return true;">http://www.jasonfleetwoodboldt.com/writing

If you'd like to reply by encrypted email you can find my public key on <a href="http://jasonfleetwoodboldt.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjasonfleetwoodboldt.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHMWKUP-j5tbyZupmruQA7b2Now4g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjasonfleetwoodboldt.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHMWKUP-j5tbyZupmruQA7b2Now4g&#39;;return true;">jasonfleetwoodboldt.com (more about setting GPG: <a href="https://gpgtools.org/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgpgtools.org%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGwT8rnfdchQ-eNTAqiNdKgqxKxYA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgpgtools.org%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGwT8rnfdchQ-eNTAqiNdKgqxKxYA&#39;;return true;">https://gpgtools.org) 



Started POST "/user/press_release/tour" for 127.0.0.1 at 2017-05-04 12:17:51 -0400
  [1m [36mActiveRecord::SchemaMigration Load (29.5ms) [0m   [1m [34mSELECT `schema_migrations`.* FROM `schema_migrations` [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
Processing by UserPressReleasesController#tour_create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"FvaOuIsGnRTD0xKAoS+ZxK05Y+g5CZz2UkerbAU5a8P5fgD/kn4L8xTkrrUuytWp/4LsgXAmMue/5dNicY+rug==", "press_release"=>{"artist_id"=>"14", "tour_id"=>"3"}, "commit"=>"Create Press release"}
  [1m [36mUser Load (1.7ms) [0m   [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [36mArtist Load (1.3ms) [0m   [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [36mTour Load (6.1ms) [0m   [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [35m (0.7ms) [0m   [1m [35mBEGIN [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [35m (0.8ms) [0m   [1m [31mROLLBACK [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
Redirected to <a href="http://localhost:3000/artists/14/tours/3" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Flocalhost%3A3000%2Fartists%2F14%2Ftours%2F3\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFOiynIG5eTAmko9W55PNnYRa8ZmQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Flocalhost%3A3000%2Fartists%2F14%2Ftours%2F3\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFOiynIG5eTAmko9W55PNnYRa8ZmQ&#39;;return true;">http://localhost:3000/artists/14/tours/3
Completed 302 Found in 1057ms (ActiveRecord: 51.7ms)


Started GET "/artists/14/tours/3" for 127.0.0.1 at 2017-05-04 12:17:53 -0400
Processing by UserToursController#show as HTML
  Parameters: {"artist_id"=>"14", "id"=>"3"}
  [1m [36mTour Load (1.3ms) [0m   [1m [34mSELECT  `tours`.* FROM `tours` WHERE `tours`.`id` = 3 LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [36mUser Load (1.6ms) [0m   [1m [34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  [1m [36mArtist Load (2.6ms) [0m   [1m [34mSELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  Rendering user/tours/show.html.erb within layouts/application
  [1m [36mTourDate Load (2.1ms) [0m   [1m [34mSELECT `tour_dates`.* FROM `tour_dates` WHERE `tour_dates`.`tour_id` = 3 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
  Rendered user/tours/show.html.erb within layouts/application (288.5ms)
  [1m [35m (1.5ms) [0m   [1m [34mSELECT COUNT(*) FROM `artists` WHERE `artists`.`user_id` = 2 [0m
  Query Trace > /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/subscriber.rb:95:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/log_subscriber.rb:83:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:102:in `finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `block in finish'
     from /home/fugee/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/notifications/fanout.rb:46:in `each'
Completed 200 OK in 3580ms (Views: 3537.0ms | ActiveRecord: 15.8ms)


 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="NTFQPGvYAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonrails-ta...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="NTFQPGvYAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/f8ae30cd-bc0c-4c4c-b91a-eba17aaade37%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/f8ae30cd-bc0c-4c4c-b91a-eba17aaade37%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/f8ae30cd-bc0c-4c4c-b91a-eba17aaade37%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/f8ae30cd-bc0c-4c4c-b91a-eba17aaade37%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

----

Jason Fleetwood-Boldt
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="NTFQPGvYAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">te...@...
<a href="http://www.jasonfleetwoodboldt.com/writing" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.jasonfleetwoodboldt.com%2Fwriting\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEDgYb2R9Pc71odefP_iaMJ_TLgaA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.jasonfleetwoodboldt.com%2Fwriting\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEDgYb2R9Pc71odefP_iaMJ_TLgaA&#39;;return true;">http://www.jasonfleetwoodboldt.com/writing

If you'd like to reply by encrypted email you can find my public key on <a href="http://jasonfleetwoodboldt.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjasonfleetwoodboldt.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGb1ZrXS-vy-0emKzzghQyxDWw2gw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjasonfleetwoodboldt.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGb1ZrXS-vy-0emKzzghQyxDWw2gw&#39;;return true;">jasonfleetwoodboldt.com (more about setting GPG: <a href="https://gpgtools.org" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgpgtools.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHndH9tmbP6n6vEQOQUZHmsUsYe9g&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgpgtools.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHndH9tmbP6n6vEQOQUZHmsUsYe9g&#39;;return true;">https://gpgtools.org) 


Debug helpers/statements go in views or controllers or can  be used in either?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0076c103-2d50-479a-97cc-80edfb63b438%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sql select rolls back trying to figure out why

Jason Fleetwood-Boldt

On May 4, 2017, at 6:02 PM, fugee ohu <[hidden email]> wrote:

Debug helpers/statements go in views or controllers or can  be used in either?


You can generally use debuggers anywhere in Ruby code. (most of the community prefers byebug I think, but I can't speak for everyone. I know some who still use pry).

In your views, sometimes I stick a debugging statement in just inside the markup, like so (assuming your view is ERB):

<% byebug %>


The only exceptions to that might be a cached partial, which won't get re-evaluated. To work around such a problem, remove the caching or clear the Rails cache. 

-Jason


If you'd like to reply by encrypted email you can find my public key on jasonfleetwoodboldt.com (more about setting GPG: https://gpgtools.org

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/197B6328-9F54-4577-BE7D-17C24B46B1C7%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.
Loading...