Forum: Ruby on Rails Can't find User model

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
185bd943ea48fb142278998ef7f136b4?d=identicon&s=25 Paul Mulligan (pmdevs)
on 2016-11-18 03:02
I have a controller, SubOrder, that my clients use to place orders with
our company. I pass in a userid, which I would like to use to find a
specific user within the controller. Seems easy, right? Here's the
relevant code (within the create action of the SubOrder controller):

    sub_order =
    user = User.find(sub_order[:userid])
        def sub_order_params

When I am running my Rspec tests to test the create action, I'm getting
the following error message:

    ActiveRecord::RecordNotFound:Couldn't find User with 'userid'=

When I run this exact code in the console, sub_order contains all the
params I passed, and user has the correct userid stored, so I'm not sure
what is going on. The only possibility I can think is that the userid is
a uuid, and I'm trying to find it by string, or something like that?
This topic is locked and can not be replied to.