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
PressRelease Exists (8.0ms) SELECT 1 AS one FROM `press_releases` WHERE `press_releases`.`id` != 188 AND `press_releases`.`slug` = 'charlie-musselwhite-and-others-to-perform-at-doheny-blues-festival-may-21-22-dana-point-california' LIMIT 1
Query Trace > (irb):1:in `irb_binding'
(6.1ms) ROLLBACK
Query Trace > (irb):1:in `irb_binding'
(5.9ms) BEGIN
Query Trace > (irb):1:in `irb_binding'
PressRelease Exists (11.2ms) SELECT 1 AS one FROM `press_releases` WHERE `press_releases`.`id` != 189 AND `press_releases`.`slug` = 'vasti-jackson-to-perform-may-15th-at-kwadendamme-blues-festival-special-guest-freek-de-jong' LIMIT 1
Query Trace > (irb):1:in `irb_binding'
(6.5ms) 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 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/6ee2f0d9-f22f-4aea-8f68-dafb81e0172d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment