Ruby on Rails Sunday, January 27, 2019



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'

--
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+unsubscribe@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/d21e9266-23aa-49e8-b8e6-f431a587739e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment