Ruby on Rails Saturday, January 26, 2019

> On Jan 26, 2019, at 11:49 PM, fugee ohu <fugee279@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

--
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/3835E9CC-92C0-4C59-B73E-54BAF36B399C%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment