> On Jan 27, 2019, at 4:11 PM, fugee ohu <fugee...@gmail.com> wrote:
> 
> 
> 
> On Sunday, January 27, 2019 at 2:43:46 PM UTC-5, Walter Lee Davis wrote:
> 
> > On Jan 27, 2019, at 7:35 AM, fugee ohu <fuge...@gmail.com> wrote: 
> > 
> > 
> > 
> > On Sunday, January 27, 2019 at 12:24:25 AM UTC-5, Walter Lee Davis wrote: 
> > 
> > > On Jan 26, 2019, at 11:49 PM, fugee ohu <fuge...@gmail.com> wrote: 
> > > 
> > > 
> > > 
> > > On Saturday, January 26, 2019 at 6:58:17 PM UTC-5, Walter Lee Davis 
> > > wrote: 
> > > 
> > > > On Jan 26, 2019, at 5:27 PM, fugee ohu <fuge...@gmail.com> wrote: 
> > > > 
> > > > TypeError: no implicit conversion of Symbol into Integer 
> > > > from app/models/press_release.rb:17:in `truncated_headline' 
> > > > 
> > > > 
> > > > class PressRelease < ApplicationRecord 
> > > > 
> > > >   extend FriendlyId 
> > > >   friendly_id :truncated_headline, use: :slugged 
> > > > 
> > > >           
> > > >   def truncated_headline 
> > > >   # cut off at 200 characters, without an ellipsis 
> > > >         headline.truncate(255, '') 
> > > >   end 
> > > > 
> > > 
> > > Aha. truncate takes named arguments past the first one. The correct 
> > > signature is 
> > > 
> > > headline.truncate(255, omission: '') 
> > > 
> > > This should work. 
> > > 
> > > Walter 
> > > 
> > > Still rolling back 
> > > 
> > > 
> > 
> > Show me an example from your development console. Copy and paste. Make sure 
> > that you include the part where we can see the parameters being passed into 
> > your controller. I suspect that you are trying to pass a type = 'admin' 
> > parameter somewhere, that's what the error looked like earlier. Type 
> > columns in polymorphic relationships must be passed a valid constant name, 
> > which will begin with an upper-case letter. If there is a model in that 
> > relationship named admin, you would pass Admin rather than admin. 
> > 
> > Walter 
> > 
> > 
> >  Loading development environment (Rails 5.2.0) 
> > 2.3.3 :001 > PressRelease.find_each(&:save) 
> >   Query Trace > (irb):1:in `irb_binding' 
> >    (24.1ms)  SET NAMES utf8,  @@SESSION.sql_mode = 
> > CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), 
> >  @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483 
> >   Query Trace > (irb):1:in `irb_binding' 
> >   PressRelease Load (53.8ms)  SELECT  `press_releases`.* FROM 
> > `press_releases` ORDER BY `press_releases`.`id` ASC LIMIT 1000 
> >   Query Trace > (irb):1:in `irb_binding' 
> >    (7.1ms)  BEGIN 
> >   Query Trace > (irb):1:in `irb_binding' 
> >   PressRelease Exists (9.4ms)  SELECT  1 AS one FROM `press_releases` WHERE 
> > `press_releases`.`id` != 2 AND `press_releases`.`slug` = 
> > 'outskirts-of-love-is-available-now-some-autographed-copies-remain' LIMIT 1 
> >   Query Trace > (irb):1:in `irb_binding' 
> >    (7.9ms)  ROLLBACK 
> >   Query Trace > (irb):1:in `irb_binding' 
> >    (5.6ms)  BEGIN 
> >   Query Trace > (irb):1:in `irb_binding' 
> >   PressRelease Exists (9.6ms)  SELECT  1 AS one FROM `press_releases` WHERE 
> > `press_releases`.`id` != 3 AND `press_releases`.`slug` = 
> > 'shemekia-copeland-to-appear-in-new-york-and-teaneck' LIMIT 1 
> >   Query Trace > (irb):1:in `irb_binding' 
> >    (6.3ms)  ROLLBACK 
> >   Query Trace > (irb):1:in `irb_binding' 
> >    (6.0ms)  BEGIN 
> >   Query Trace > (irb):1:in `irb_binding' 
> >   PressRelease Exists (12.7ms)  SELECT  1 AS one FROM `press_releases` 
> > WHERE `press_releases`.`id` != 5 AND `press_releases`.`slug` = 
> > 'al-basile-creates-new-roots-music-masterpiece-with-b-s-expression-due-september-18-on-sweetspot-records-latest-release-is-most-fully-realized-album-yet'
> >  LIMIT 1 
> >   Query Trace > (irb):1:in `irb_binding' 
> >    (8.1ms)  ROLLBACK 
> >   Query Trace > (irb):1:in `irb_binding' 
> >    (6.0ms)  BEGIN 
> >   Query Trace > (irb):1:in `irb_binding' 
> >   PressRelease Exists (8.9ms)  SELECT  1 AS one FROM `press_releases` WHERE 
> > `press_releases`.`id` != 6 AND `press_releases`.`slug` = 
> > 'new-cd-from-british-blues-godfather-john-mayall-find-a-way-to-care-set-for-release-september-4th-on-forty-below-records-vinyl-lp-to-follow-in-fall'
> >  LIMIT 1 
> >   Query Trace > (irb):1:in `irb_binding' 
> >    (6.8ms)  ROLLBACK 
> >   Query Trace > (irb):1:in `irb_binding' 
> > 
> > 
> 
> Okay, since you're not in the development console, and aren't handling a PUT 
> or PATCH, you don't have parameters to look at here. So this is less useful 
> than I had hoped. Please answer these questions, preferably inline, so I 
> don't have to play hunt-and-peck to figure this out. 
> 
> 1. When you added FriendlyId to your app, did you use the built-in generator 
> to add the friendly_id_slugs table to your app? 
> 
> 2. After you added gem 'friendly_id' to your Gemfile, and ran bundle install, 
> did you at any point after that do anything that caused the friendly_id gem 
> to upgrade to a newer version? Hint: look through the git history on your 
> Gemfile.lock file, and look for any (upward, I'm guessing) movement of the 
> version number of the friendly_id gem. The line you are looking at will be 
> the one that reads something like 
> 
>   friendly_id (5.2.5) 
> 
> with nothing else on the same line. Any other reference to friendly_id will 
> be in dependencies, not the actual version of the gem that your app is 
> loading and running. 
> 
> 3. What happens if you change &:save to &:save! (with a bang!) in order to 
> die spectacularly and throw a visible error? 
> 
> 4. What happens if you unroll the Symbol-to-Proc sugar into its long-hand 
> equivalent? Example: 
> 
> YourModel.find_each do |instance| 
>   instance.save! 
>   puts instance.errors.full_messages 
> end 
> 
> That should die after the first model with errors, and throw out a more 
> useful error message than ROLLBACK. 
> 
> If the answer to #2 is Yes, then you will probably need to read through the 
> upgrade instructions on the FriendlyId project README on GitHub, and figure 
> out what you didn't do. That's not likely to be the problem, but I put it out 
> there because this project has had some tectonic shifts in its schema, and 
> all of them are covered with extra migrations that you optionally run when 
> you update. Missing any of these could cause the whole thing to fail. But 
> that's only likely if you started with FriendlyId a while ago, and then did 
> something unrelated with Bundler that caused this gem to upgrade further than 
> you were expecting. Particularly if you see that the version has changed in 
> the major number, like from 3.x.x to 4.x.x, that's when you would want to be 
> very careful to check those instructions. 
> 
> Walter 
> 
> 
>  ActiveRecord::RecordInvalid: translation missing: 
> en-US.activerecord.errors.messages.record_invalid
>       from (irb):1
> 

This is interesting. Try removing the .full_messages part and run this again. 
You have an invalid record, which means it can't be saved. You have to figure 
out what the error is. What validations do you have on the object? What 
validations do you have on the related models? What requirements are you 
missing? That's where your problem is -- this has zero to do with friendly_id.

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-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/0055fa7d-84e6-4082-83ca-f9e18aeb78ad%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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/9084CBE6-44B4-4E58-AEC7-B1B15CD02948%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to