Forum: Ruby on Rails Can't find User model

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 = SubOrder.new(sub_order_params)
    user = User.find(sub_order[:userid])
    ...
    private
        def sub_order_params
            params.require(:sub_order).permit(:userid...
        end

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?
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.