All threads / "rails for beginners part 21"

Ask A Question

Notifications

You’re not receiving notifications from this thread.

"rails for beginners part 21"

gabriele garretto asked in Rails

i cant make work user.signed_id, it raises a no_method_error:

irb(main):010:0> user.signed_id
Traceback (most recent call last):
2: from (irb):9
1: from (irb):10:in rescue in irb_binding'
NoMethodError (undefined method
signed_id' for #User:0x00007fc2ad38d728)

fiddling around i tryed user.to_signed_global_id:

irb(main):011:0> user.to_signed_global_id.to_s
=> "BAh7CEkiCGdpZAY6BkVUSSIaZ2lkOi8vZmlzaHJvb20vVXNlci84BjsAVEkiDHB1cnBvc2UGOwBUSSIMZGVmYXVsdAY7AFRJIg9leHBpcmVzX2F0BjsAVEkiHTIwMjEtMDMtMDlUMTU6Mzc6NDUuNzM3WgY7AFQ=--3d69db1dd78c21da26d108891727e32948b1d3f3"
irb(main):012:0> user.to_signed_global_id(expires_in:15.minutes)
=> #, @verifier=#, @purpose="default", @expires_at=Tue, 09 Feb 2021 15:54:00 UTC +00:00>
irb(main):013:0>

is this the same thing as signed_id? why in the video of chris this all thing does work?

Make sure you're using the latest Rails version. I don't think this works in older Rails versions.

thanks for the answer chris, i actually was running rails 6.0, since I'm implementing this course on an app that i was already building on 6.0, do you think i should upgrade it or i risk to brake something?

The Rails 6.0 to 6.1 is really simple, so you should be fine upgrading. 👍

The update task is pretty easy: bin/rails app:update

And of course, all the details are here: https://guides.rubyonrails.org/upgrading_ruby_on_rails.html

thank you very much, you'r the man!🙌

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 48,387+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.