Rails 5 : Devise Oauth Referral param not saved - ruby-on-rails

I have an app where user can register using email, facebook or google, also I have small referral system where user can share link and earn points.
Now everything works perfectly registering and login. But referral system works only when creating account using social networks.
the following is my code :
omniauth_callbacks_controller.rb
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
# You need to implement the method below in your model (e.g. app/models/user.rb)
#user = User.from_omniauth(request.env["omniauth.auth"])
if #user.persisted?
sign_in_and_redirect #user, event: :authentication
#this will throw if #user is not activated
set_flash_message(:notice, :success, kind: "Facebook") if is_navigational_format?
else
session["devise.facebook_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
# google callback
def google_oauth2
#user = User.from_omniauth(request.env['omniauth.auth'])
if #user.persisted?
sign_in_and_redirect #user
set_flash_message(:notice, :success, kind: 'Google') if is_navigational_format?
else
flash[:error] = 'There was a problem signing you in through Google. Please register or try signing in later.'
redirect_to new_user_registration_url
end
end
def failure
flash[:error] = 'There was a problem signing you in. Please register or try signing in later.'
redirect_to new_user_registration_url
end
end
registrations_controller.rb
def build_resource(hash = {})
super
if cookies[:referral_code] && referrer = User.find_by(referral_code: cookies[:referral_code])
self.resource.referred_by = referrer
end
end
user.rb
before_validation :set_referral_code
validates :referral_code, uniqueness: true
def set_referral_code
loop do
self.referral_code = SecureRandom.hex(6)
break unless self.class.exists?(referral_code: referral_code)
end
end
application_controller.rb
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
before_action :set_referral_cookie
def set_referral_cookie
if params[:ref]
cookies[:referral_code] = {
value: params[:ref],
expires: 30.days.from_now,
}
end
end
I built my system using help of this repository
gorails referral system
Edit
Started GET "/?ref=6c28f9668715" for 127.0.0.1 at 2019-01-27 21:23:32 +0100
Processing by HomeController#index as HTML
Parameters: {"ref"=>"6c28f9668715"}
Rendering home/index.html.erb within layouts/application
Rendered home/index.html.erb within layouts/application (0.6ms)
Rendered shared/_navbar.html.erb (1.4ms)
Completed 200 OK in 125ms (Views: 90.7ms | ActiveRecord: 0.0ms)
Started GET "/users/sign_up" for 127.0.0.1 at 2019-01-27 21:23:34 +0100
Processing by Users::RegistrationsController#new as HTML
User Load (1.6ms) SELECT "users".* FROM "users" WHERE "users"."referral_code" = $1 LIMIT $2 [["referral_code", "6c28f9668715"], ["LIMIT", 1]]
↳ app/controllers/users/registrations_controller.rb:7
Rendering users/registrations/new.html.erb within layouts/application
Rendered users/registrations/new.html.erb within layouts/application (6.7ms)
Rendered shared/_navbar.html.erb (1.2ms)
Completed 200 OK in 300ms (Views: 142.0ms | ActiveRecord: 1.6ms)
Started GET "/users/auth/facebook" for 127.0.0.1 at 2019-01-27 21:23:37 +0100
I, [2019-01-27T21:23:37.266108 #67828] INFO -- omniauth: (facebook) Request phase initiated.
Started GET "/users/auth/facebook" for 127.0.0.1 at 2019-01-27 21:23:38 +0100
I, [2019-01-27T21:23:38.488342 #67828] INFO -- omniauth: (facebook) Request phase initiated.
Started GET "/users/auth/facebook/callback?code=AQAemLam_HRACk1q5NTfix5Sve6rA1fsDD5z_21vKpDlaTq4hfuXM2Oh_CThPspwk1BIg4Tjc1bm0UOcXLo_X0XGVI8XdLsirhPV6wKnGiCO3uU3l4y6y31qnhC1xjzd-21wx_cWVO-ipPCzrZ8kqWCdvQrxxKOQXMj10LsKlTAbuSqMEpx90XvcZw3RAYGLSiEFQGJSgCpABpboh_n_ewjTbfbTB01JATW6hM9Wy8iN1AQLpXrRgOZ-5P1NdowqdHdjU420N6QoB7R9tyHXegioQ47J8cjgCMUFwDPi_T--zHK6_-sIkW_QE6P5ryot1qHxzHpOASvx46WHvJun5_Yh&state=bd3dfbf7e7a5c83c42d1d754149d7be5ea7f39b6d5b99b28" for 127.0.0.1 at 2019-01-27 21:23:39 +0100
I, [2019-01-27T21:23:39.483990 #67828] INFO -- omniauth: (facebook) Callback phase initiated.
Processing by Users::OmniauthCallbacksController#facebook as HTML
Parameters: {"code"=>"AQAemLam_HRACk1q5NTfix5Sve6rA1fsDD5z_21vKpDlaTq4hfuXM2Oh_CThPspwk1BIg4Tjc1bm0UOcXLo_X0XGVI8XdLsirhPV6wKnGiCO3uU3l4y6y31qnhC1xjzd-21wx_cWVO-ipPCzrZ8kqWCdvQrxxKOQXMj10LsKlTAbuSqMEpx90XvcZw3RAYGLSiEFQGJSgCpABpboh_n_ewjTbfbTB01JATW6hM9Wy8iN1AQLpXrRgOZ-5P1NdowqdHdjU420N6QoB7R9tyHXegioQ47J8cjgCMUFwDPi_T--zHK6_-sIkW_QE6P5ryot1qHxzHpOASvx46WHvJun5_Yh", "state"=>"bd3dfbf7e7a5c83c42d1d754149d7be5ea7f39b6d5b99b28"}
User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."provider" = $1 AND "users"."uid" = $2 ORDER BY "users"."id" ASC LIMIT $3 [["provider", "facebook"], ["uid", "311741132783400"], ["LIMIT", 1]]
↳ app/models/user.rb:60
Disk Storage (5.7ms) Uploaded file to key: Sp8DiDxRWFn3uUfGTJJHdABc (checksum: tjmoDYRADOqNyXiWy90gxg==)
(0.3ms) BEGIN
↳ app/models/user.rb:66
ActiveStorage::Blob Create (44.9ms) INSERT INTO "active_storage_blobs" ("key", "filename", "content_type", "metadata", "byte_size", "checksum", "created_at") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id" [["key", "Sp8DiDxRWFn3uUfGTJJHdABc"], ["filename", "avatar.jpg"], ["content_type", "image/jpeg"], ["metadata", "{\"identified\":true}"], ["byte_size", 1640], ["checksum", "tjmoDYRADOqNyXiWy90gxg=="], ["created_at", "2019-01-27 20:23:42.423862"]]
↳ /Users/qubitam/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/globalize-3fe2f93ab2d0/lib/patches/active_record/persistence.rb:12
(0.9ms) COMMIT
↳ app/models/user.rb:66
(0.2ms) BEGIN
↳ app/models/user.rb:66
(0.2ms) COMMIT
↳ app/models/user.rb:66
(0.2ms) BEGIN
↳ app/models/user.rb:60
User Exists (0.4ms) SELECT 1 AS one FROM "users" WHERE "users"."provider" = $1 AND "users"."uid" = $2 AND "users"."referral_code" = $3 LIMIT $4 [["provider", "facebook"], ["uid", "311741132783400"], ["referral_code", "2925f372e912"], ["LIMIT", 1]]
↳ app/models/user.rb:79
User Exists (0.4ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2 [["email", "qubitam#gmail.com"], ["LIMIT", 1]]
↳ /Users/qubitam/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/globalize-3fe2f93ab2d0/lib/patches/active_record/rails5_1/uniqueness_validator.rb:38
User Exists (0.3ms) SELECT 1 AS one FROM "users" WHERE "users"."referral_code" = $1 LIMIT $2 [["referral_code", "2925f372e912"], ["LIMIT", 1]]
↳ /Users/qubitam/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/globalize-3fe2f93ab2d0/lib/patches/active_record/rails5_1/uniqueness_validator.rb:38
User Create (2.5ms) INSERT INTO "users" ("email", "encrypted_password", "name", "created_at", "updated_at", "provider", "uid", "referral_code") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" [["email", "qubitam#gmail.com"], ["encrypted_password", "$2a$11$JUxrDl1I4uDQwxi3yRVrnuqRJNYQJA8BcvLrmAj29nwBggJknrP3i"], ["name", "Abdelmoumin Mokhtari"], ["created_at", "2019-01-27 20:23:42.483417"], ["updated_at", "2019-01-27 20:23:42.483417"], ["provider", "facebook"], ["uid", "311741132783400"], ["referral_code", "2925f372e912"]]
↳ /Users/qubitam/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/globalize-3fe2f93ab2d0/lib/patches/active_record/persistence.rb:12
ActiveStorage::Attachment Create (0.7ms) INSERT INTO "active_storage_attachments" ("name", "record_type", "record_id", "blob_id", "created_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "image"], ["record_type", "User"], ["record_id", 13], ["blob_id", 10], ["created_at", "2019-01-27 20:23:42.487979"]]
↳ /Users/qubitam/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/globalize-3fe2f93ab2d0/lib/patches/active_record/persistence.rb:12
User Update (41.5ms) UPDATE "users" SET "updated_at" = $1 WHERE "users"."id" = $2 [["updated_at", "2019-01-27 20:23:42.490719"], ["id", 13]]
↳ app/models/user.rb:60
(40.9ms) COMMIT
↳ app/models/user.rb:60
[ActiveJob] Enqueued ActiveStorage::AnalyzeJob (Job ID: 1f7ce124-dc8b-4302-912e-7b1138656e35) to Async(default) with arguments: #<GlobalID:0x00007fa636abf0e8 #uri=#<URI::GID gid://classifyads/ActiveStorage::Blob/10>>
(1.0ms) BEGIN
↳ app/controllers/users/omniauth_callbacks_controller.rb:8
ActiveStorage::Blob Load (0.4ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2 [["id", 10], ["LIMIT", 1]]
↳ /Users/qubitam/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.2.2/lib/active_record/log_subscriber.rb:98
[ActiveJob] [ActiveStorage::AnalyzeJob] [1f7ce124-dc8b-4302-912e-7b1138656e35] Performing ActiveStorage::AnalyzeJob (Job ID: 1f7ce124-dc8b-4302-912e-7b1138656e35) from Async(default) with arguments: #<GlobalID:0x00007fa636aac790 #uri=#<URI::GID gid://classifyads/ActiveStorage::Blob/10>>
[ActiveJob] [ActiveStorage::AnalyzeJob] [1f7ce124-dc8b-4302-912e-7b1138656e35] Disk Storage (0.2ms) Downloaded file from key: Sp8DiDxRWFn3uUfGTJJHdABc
[ActiveJob] [ActiveStorage::AnalyzeJob] [1f7ce124-dc8b-4302-912e-7b1138656e35] Skipping image analysis because the mini_magick gem isn't installed
[ActiveJob] [ActiveStorage::AnalyzeJob] [1f7ce124-dc8b-4302-912e-7b1138656e35] (0.2ms) BEGIN
[ActiveJob] [ActiveStorage::AnalyzeJob] [1f7ce124-dc8b-4302-912e-7b1138656e35] ↳ /Users/qubitam/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.2.2/lib/active_record/log_subscriber.rb:98
[ActiveJob] [ActiveStorage::AnalyzeJob] [1f7ce124-dc8b-4302-912e-7b1138656e35] ActiveStorage::Blob Update (0.6ms) UPDATE "active_storage_blobs" SET "metadata" = $1 WHERE "active_storage_blobs"."id" = $2 [["metadata", "{\"identified\":true,\"analyzed\":true}"], ["id", 10]]
[ActiveJob] [ActiveStorage::AnalyzeJob] [1f7ce124-dc8b-4302-912e-7b1138656e35] ↳ /Users/qubitam/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/globalize-3fe2f93ab2d0/lib/patches/active_record/persistence.rb:7
User Update (82.8ms) UPDATE "users" SET "sign_in_count" = $1, "current_sign_in_at" = $2, "last_sign_in_at" = $3, "current_sign_in_ip" = $4, "last_sign_in_ip" = $5, "updated_at" = $6 WHERE "users"."id" = $7 [["sign_in_count", 1], ["current_sign_in_at", "2019-01-27 20:23:42.581519"], ["last_sign_in_at", "2019-01-27 20:23:42.581519"], ["current_sign_in_ip", "127.0.0.1/32"], ["last_sign_in_ip", "127.0.0.1/32"], ["updated_at", "2019-01-27 20:23:42.584122"], ["id", 13]]
↳ /Users/qubitam/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/globalize-3fe2f93ab2d0/lib/patches/active_record/persistence.rb:7
[ActiveJob] [ActiveStorage::AnalyzeJob] [1f7ce124-dc8b-4302-912e-7b1138656e35] (61.8ms) COMMIT
[ActiveJob] [ActiveStorage::AnalyzeJob] [1f7ce124-dc8b-4302-912e-7b1138656e35] ↳ /Users/qubitam/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.2.2/lib/active_record/log_subscriber.rb:98
[ActiveJob] [ActiveStorage::AnalyzeJob] [1f7ce124-dc8b-4302-912e-7b1138656e35] Performed ActiveStorage::AnalyzeJob (Job ID: 1f7ce124-dc8b-4302-912e-7b1138656e35) from Async(default) in 122.16ms
(79.1ms) COMMIT
↳ app/controllers/users/omniauth_callbacks_controller.rb:8
Redirected to http://localhost:3000/users/edit
Completed 302 Found in 2383ms (ActiveRecord: 297.1ms)
Started GET "/users/edit" for 127.0.0.1 at 2019-01-27 21:23:42 +0100
Processing by Users::RegistrationsController#edit as HTML
User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 13], ["LIMIT", 1]]
↳ /Users/qubitam/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.2.2/lib/active_record/log_subscriber.rb:98
Rendering users/registrations/edit.html.erb within layouts/application
ActiveStorage::Attachment Load (0.6ms) SELECT "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_id" = $1 AND "active_storage_attachments"."record_type" = $2 AND "active_storage_attachments"."name" = $3 LIMIT $4 [["record_id", 13], ["record_type", "User"], ["name", "image"], ["LIMIT", 1]]
↳ app/views/users/registrations/edit.html.erb:8
ActiveStorage::Blob Load (0.9ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2 [["id", 10], ["LIMIT", 1]]
↳ app/views/users/registrations/edit.html.erb:8
Rendered users/registrations/edit.html.erb within layouts/application (14.4ms)
Rendered shared/_navbar.html.erb (3.9ms)
Completed 200 OK in 105ms (Views: 100.1ms | ActiveRecord: 2.2ms)

Related

Rails - Devise's registration controller create action seems to trigger twice

I added this lines of code to create action:
def create
super
#card = Card.find(params[:card_id])
#card.update(:user_id=>current_user)
end
And everything works fine, user gets created, card gets updated, but after redirect this happens:
Couldn't find Card with 'id'=
Extracted source (around line #14):
def create
super
#card = Card.find(params[:card_id])
#card.update(:user_id=>current_user)
end
I checked my terminal to find out the reason why this happens, and it seems that create action triggers twice for no reason:
Started POST "/users" for ::1 at 2020-08-12 11:04:34 +0300
Processing by Users::RegistrationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"q1W0+ZhzK85uHTcp1x4jKHvCG0ukIgj2JxZuAy6vuLQl/vPqJVu6eXSEWviYTnWC4cXAJk2xCJhl8mgoWzXIAA==", "user"=>{"name"=>"Терл Кабот", "email"=>"tafff1#gmail.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "card_id"=>"2000012606"}, "commit"=>"Sign up"}
Card Load (1.0ms) SELECT "cards".* FROM "cards" WHERE "cards"."id" = $1 LIMIT $2 [["id", 2000012606], ["LIMIT", 1]]
(0.0ms)
BEGIN
User Exists (1.0ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2 [["email", "tafff1#gmail.com"], ["LIMIT", 1]]
SQL (1.0ms) INSERT INTO "users" ("email", "encrypted_password", "name", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["email", "tafff1#gmail.com"], ["encrypted_password", "$2a$12$qTrv/zFUxULi9sqWgYlY/uPjQoJsZxB8PJK2ae/e6YfAFT40ci47e"], ["name", "Терл Кабот"], ["created_at", "2020-08-12 08:04:35.174621"], ["updated_at", "2020-08-12 08:04:35.174621"]]
SQL (1.0ms) UPDATE "cards" SET "user_id" = $1, "updated_at" = $2 WHERE "cards"."id" = $3 [["user_id", 17], ["updated_at", "2020-08-12 08:04:35.178626"], ["id", 2000012606]]
(1.0ms) COMMIT
Redirected to http://localhost:3000/
Card Load (0.0ms) SELECT "cards".* FROM "cards" WHERE "cards"."id" = $1 LIMIT $2 [["id", nil], ["LIMIT", 1]]
Completed 404 Not Found in 378ms (ActiveRecord: 6.0ms)
ActiveRecord::RecordNotFound (Couldn't find Card with 'id'=):
is there any solution for this?
EDIT: I gave up and just changed card and user logic, now user belongs to card, so I dont have to update cards user_id from devises create action.
The card_id is nested in the user key, so it will be: params[:user][:card_id]

Partially working simple image upload using Active Storage

Any help or guidance would be most appreciated.
I've followed the Rails Guide, however, and I can upload an image to a model. However, it produces an error.
I've copied what the error suggests and that produces another error and does not upload an image.
Many, many thanks in advance!
This works but produces an error post form submission. If I hit back and then visit the specific prod id product#show the image has uploaded.
Error
NameError in ProductsController#create
undefined local variable or method `product' for # Did you mean? #product
Products.rb
def create
#list = List.find(params[:list_id])
#product = #list.products.create(product_params)
product.hero.attach(params[:hero])
redirect_to list_path(#list)
end
This does not work however, looks syntactically correct as the "#product" model attaches to the :hero .
Products.rb
def create
#list = List.find(params[:list_id])
#product = #list.products.create(product_params)
#product.hero.attach(params[:hero])
redirect_to list_path(#list)
end
creates the product
refreshes the screen back to the product list so it looks correct.
This breaks producing two errors:
The first error on products#show
ArgumentError in Products#show
Showing /Users/user/rubyonrails/shopping/app/views/products/show.html.erb where line #2 raised:
Can't resolve image into URL: to_model delegated to attachment, but the attachment is nil
Second terminal output presents the upload seems to work then something called Active Storage Purge fires up removing it?
ActiveStorage::Blob Load (0.3ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2 [["id", 7], ["LIMIT", 1]]
[ActiveJob] [ActiveStorage::PurgeJob] [e9b35a62-ff6c-4a38-8946-3aa9c19668ef] Performing ActiveStorage::PurgeJob (Job ID: e9b35a62-ff6c-4a38-8946-3aa9c19668ef) from Async(active_storage_purge) enqueued at 2020-04-15T11:31:41Z with arguments: #<GlobalID:0x00007f92b1da3d60 #uri=#<URI::GID gid://shopping/ActiveStorage::Blob/7>>
[ActiveJob] [ActiveStorage::AnalyzeJob] [b724849f-6993-4130-bef1-a0f8837a3171] (6.4ms) COMMIT
[ActiveJob] [ActiveStorage::PurgeJob] [e9b35a62-ff6c-4a38-8946-3aa9c19668ef] (0.8ms) BEGIN
[ActiveJob] [ActiveStorage::AnalyzeJob] [b724849f-6993-4130-bef1-a0f8837a3171] Performed ActiveStorage::AnalyzeJob (Job ID: b724849f-6993-4130-bef1-a0f8837a3171) from Async(active_storage_analysis) in 15.88ms
Started GET "/lists/9" for ::1 at 2020-04-15 12:31:41 +0100
[ActiveJob] [ActiveStorage::PurgeJob] [e9b35a62-ff6c-4a38-8946-3aa9c19668ef] ActiveStorage::Attachment Exists? (0.5ms) SELECT 1 AS one FROM "active_storage_attachments" WHERE "active_storage_attachments"."blob_id" = $1 LIMIT $2 [["blob_id", 7], ["LIMIT", 1]]
Processing by ListsController#show as HTML
[ActiveJob] [ActiveStorage::PurgeJob] [e9b35a62-ff6c-4a38-8946-3aa9c19668ef] ActiveStorage::Attachment Load (1.1ms) SELECT "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_id" = $1 AND "active_storage_attachments"."record_type" = $2 AND "active_storage_attachments"."name" = $3 LIMIT $4 [["record_id", 7], ["record_type", "ActiveStorage::Blob"], ["name", "preview_image"], ["LIMIT", 1]]
Parameters: {"id"=>"9"}
[ActiveJob] [ActiveStorage::PurgeJob] [e9b35a62-ff6c-4a38-8946-3aa9c19668ef] ActiveStorage::Blob Destroy (1.0ms) DELETE FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 [["id", 7]]
List Load (0.9ms) SELECT "lists".* FROM "lists" WHERE "lists"."id" = $1 LIMIT $2 [["id", 9], ["LIMIT", 1]]
↳ app/controllers/lists_controller.rb:7:in `show'
Product Load (0.2ms) SELECT "products".* FROM "products" WHERE "products"."id" = $1 LIMIT $2 [["id", 9], ["LIMIT", 1]]
↳ app/controllers/lists_controller.rb:8:in `show'
Rendering lists/show.html.erb within layouts/application
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
↳ app/views/lists/show.html.erb:2
Product Exists? (0.2ms) SELECT 1 AS one FROM "products" WHERE "products"."list_id" = $1 LIMIT $2 [["list_id", 9], ["LIMIT", 1]]
↳ app/views/lists/show.html.erb:5
Product Load (0.2ms) SELECT "products".* FROM "products" WHERE "products"."list_id" = $1 [["list_id", 9]]
↳ app/views/lists/show.html.erb:6
[ActiveJob] [ActiveStorage::PurgeJob] [e9b35a62-ff6c-4a38-8946-3aa9c19668ef] (6.4ms) COMMIT
(0.8ms) SELECT COUNT(*) FROM "products" WHERE "products"."list_id" = $1 [["list_id", 9]]
[ActiveJob] [ActiveStorage::PurgeJob] [e9b35a62-ff6c-4a38-8946-3aa9c19668ef] Disk Storage (0.2ms) Deleted file from key: 31cfuow9pj6vjqhq8i479fdxf1lc
↳ app/controllers/application_controller.rb:5:in `product_list_size?'
[ActiveJob] [ActiveStorage::PurgeJob] [e9b35a62-ff6c-4a38-8946-3aa9c19668ef] Disk Storage (0.1ms) Deleted files by key prefix: variants/31cfuow9pj6vjqhq8i479fdxf1lc/
Rendered lists/show.html.erb within layouts/application (Duration: 9.5ms | Allocations: 7278)
[ActiveJob] [ActiveStorage::PurgeJob] [e9b35a62-ff6c-4a38-8946-3aa9c19668ef] Performed ActiveStorage::PurgeJob (Job ID: e9b35a62-ff6c-4a38-8946-3aa9c19668ef) from Async(active_storage_purge) in 22.5ms
[Webpacker] Everything's up-to-date. Nothing to do
List item
Egg on my face.
The exclamation mark omission seems to be the issue.
from
#product = #list.products.create(product_params)
to this and it works
#product = #list.products.create!(product_params)

Cannot access user model from Devise sessions controller: [merit] no target_obj found on Rule#applies?

I have
class CustomSessionsController < Devise::SessionsController
def create
#user = resource # needed for Merit
super
end
protected
def after_sign_in_path_for(resource)
#user = resource # needed for Merit
resource.update_streak
super
And
grant_on 'custom_sessions#create', badge: :streak, level: 3, temporary: true, model_name: 'User' do |user|
puts user.inspect
user.streak.count >= 3
end
But it gives the error
[merit] no target_obj found on Rule#applies?
And I can't access the model and it doesn't grant the badge or log the user. What is wrong? I followed the guide.
https://github.com/merit-gem/merit/wiki/How-to-grant-badges-on-user-using-Devise
It's doing something.
Processing by CustomSessionsController#create as HTML
Parameters: {"utf8"=>"√", "authenticity_token"=>"gqUQjF9hfzJdQqxAAQJxv7bi+kZYwuv1NWtOP0YhkbjHKwnfa5WAb/CkRZ5c+Xi5yVlnJ2v774w3XLhTa1b1sQ==", "user"=>{"email"=>"student#gmail.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Log in"}
User Load (6.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["email", "student#gmail.com"]]
(7.0ms) BEGIN
SQL (3.0ms) UPDATE "users" SET "last_sign_in_at" = $1, "current_sign_in_at" = $2, "sign_in_count" = $3, "updated_at" = $4 WHERE "users"."id" = $5 [["last_sign_in_at", "2018-08-09 05:38:58.345271"], ["current_sign_in_at", "2018-08-10 01:40:51.644592"], ["sign_in_count", 15], ["updated_at", "2018-08-10 01:40:51.668609"], ["id", 3]]
(25.0ms) COMMIT
Streak Load (21.0ms) SELECT "streaks".* FROM "streaks" WHERE "streaks"."user_id" = $1 LIMIT 1 [["user_id", 3]]
Redirected to http://localhost:3000/
(1.0ms) BEGIN
SQL (7.0ms) INSERT INTO "merit_actions" ("user_id", "action_method", "target_model", "target_data", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id" [["user_id", 3], ["action_method", "create"], ["target_model", "custom_sessions"], ["target_data", "--- \n...\n"], ["created_at", "2018-08-10 01:40:53.539847"], ["updated_at", "2018-08-10 01:40:53.539847"]]
(8.0ms) COMMIT
Merit::Action Load (6.0ms) SELECT "merit_actions".* FROM "merit_actions" WHERE "merit_actions"."processed" = $1 [["processed", "f"]]
(3.0ms) BEGIN
SQL (2.0ms) UPDATE "merit_actions" SET "processed" = $1, "updated_at" = $2 WHERE "merit_actions"."id" = $3 [["processed", "t"], ["updated_at", "2018-08-10 01:40:53.581875"], ["id", 17]]
(20.0ms) COMMIT
User Load (2.0ms) SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1
[merit] no target_obj found on Rule#applies?
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1
[merit] no target_obj found on Rule#applies?
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1
Completed 302 Found in 2567ms (ActiveRecord: 293.2ms)
Merit 2.4, Rails 4.2.
I tried
grant_on 'custom_sessions#create', badge: :streak, level: 3, temporary: true do
puts current_user.inspect
current_user.streak.count >= 3
end
But it gave
[merit] no target found: uninitialized constant CustomSession. base_target_finder.rb:13:in 'find'
error NameError (undefined local variable or method 'current_user'
I tried
grant_on 'custom_sessions#create', badge: :streak, level: 3, temporary: true, to: :itself do |user|
puts user.inspect
user.streak.count >= 3
end
def create
#custom_session = resource # needed for Merit
def after_sign_in_path_for(resource)
#custom_session = resource # needed for Merit
But it gave
[merit] no target found: uninitialized constant CustomSession. C:/ruby23/lib/ruby/gems/2.3.0/gems/merit-2.4.0/lib/merit/base_target_finder.rb:13:in `find'
true
Completed 500 Internal Server Error in 2181ms (ActiveRecord: 177.1ms)
NoMethodError (undefined method `streak' for true:TrueClass):
app/models/merit/badge_rules.rb:43:in `block in initialize'
I got it working with
grant_on 'custom_sessions#create', badge: :streak, level: 3, temporary: true, model_name: 'User', to: :itself do |user|
def create
super
#custom_session = resource # needed for Merit
But I don't know why because the /users/sign_in path does not have an :id parameter.
https://github.com/merit-gem/merit#how-merit-finds-the-target-object
Merit would fetch the Article object from the database, found by the :id param sent in that update action.

Ruby OAuth2 timeout error getting Token

I posted this of the issues page for the doorkeeper gem, but looking at it, I wonder if I should post here, any help would be amazing as I am completely stuck
I have been following the wiki on doorkeeper and doing the "Testing your provider with OAuth2 gem" (https://github.com/doorkeeper-gem/doorkeeper/wiki/Testing-your-provider-with-OAuth2-gem)
I am running rails 5.1.4, ruby 2.4.1, doorkeeper gem 4.2.6 and oauth2 v1.4.0
I am having issues trying to do what is done in the testing wiki in code, which is get an auth token
My sessions controller:
def new
session[:state] = 'some state sent from amazon'
session[:client_id] = 'some client id'
session[:client_secret] = 'some client secret'
session[:redirect_uri] = "#{request.base_url}/oauth/callback"
end
def create
user = User.find_by(email: params[:session][:email].downcase)
if user && user.authenticate(params[:session][:password])
if user.activated?
log_in user
redirect_to client.auth_code.authorize_url(:redirect_uri => session[:redirect_uri])
end
end
end
#route for /oauth/cllback comes here
def callback
token = client.auth_code.get_token(params[:code], :redirect_uri => session[:redirect_uri])
# testing print to screen
render json: token
end
private
def client
OAuth2::Client.new(session[:client_id], session[:client_secret], :site => request.base_url)
end
So as a user i log in, I authorise the app and then it times out and I get the following log for the whole flow:
Started GET "/login?client_id=<client_id>&response_type=code&state=<amazon state>&redirect_uri=https%3A%2F%2Fpitangui.amazon.com%2Fapi%2Fskill%2Flink%2FM2X1TLJOHDU07S" for 5.175.83.20 at 2017-10-23 13:36:35 +0100
Processing by SessionsController#new as HTML
Parameters: {"client_id"=>"<client_id>", "response_type"=>"code", "state"=>"<amazon state>", "redirect_uri"=>"https://pitangui.amazon.com/api/skill/link/M2X1TLJOHDU07S"}
Rendering sessions/new.html.erb within layouts/application
Rendered sessions/new.html.erb within layouts/application (1.5ms)
Rendered layouts/_shim.html.erb (0.5ms)
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
Rendered layouts/_header.html.erb (36.3ms)
Completed 200 OK in 121ms (Views: 107.5ms | ActiveRecord: 4.0ms)
Started POST "/login" for 5.175.83.20 at 2017-10-23 13:40:35 +0100
Processing by SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"aR03Eo+jxzN+oDPrnOevHn6moTCSePoLAi2Ncc7pKbtxVQa6lLu+IzdEsfzrexpJVm6MdOugIQICyN2ZNS7hgw==", "session"=>{"email"=>"me#daviesp.co.uk", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Log In"}
User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."email" = $1 LIMIT $2 [["email", "me#daviesp.co.uk"], ["LIMIT", 1]]
Redirected to https://3751d64e.ngrok.io/oauth/authorize?client_id=<client_id>&redirect_uri=https%3A%2F%2F3751d64e.ngrok.io%2Foauth%2Fcallback&response_type=code
Completed 302 Found in 67ms (ActiveRecord: 0.6ms)
Started GET "/oauth/authorize?client_id=<client_id>&redirect_uri=https%3A%2F%2F3751d64e.ngrok.io%2Foauth%2Fcallback&response_type=code" for 5.175.83.20 at 2017-10-23 13:40:36 +0100
Processing by Doorkeeper::AuthorizationsController#new as HTML
Parameters: {"client_id"=>"<client_id>", "redirect_uri"=>"https://3751d64e.ngrok.io/oauth/callback", "response_type"=>"code"}
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
Doorkeeper::Application Load (0.4ms) SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."uid" = $1 LIMIT $2 [["uid", "6067fbe8f36b4343aa297ce76348e868f9ea04b04841adb411d0885c491c1d48"], ["LIMIT", 1]]
CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
Doorkeeper::AccessToken Load (0.5ms) SELECT "oauth_access_tokens".* FROM "oauth_access_tokens" WHERE "oauth_access_tokens"."application_id" = $1 AND "oauth_access_tokens"."resource_owner_id" = $2 AND "oauth_access_tokens"."revoked_at" IS NULL ORDER BY created_at desc LIMIT $3 [["application_id", 11], ["resource_owner_id", 1], ["LIMIT", 1]]
CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
(0.2ms) BEGIN
Doorkeeper::AccessGrant Exists (0.6ms) SELECT 1 AS one FROM "oauth_access_grants" WHERE "oauth_access_grants"."token" = $1 LIMIT $2 [["token", "a6bd0459570f1e0116ca6b2cade1e60ae83ba439d3c70b750046cfffe3cc85e4"], ["LIMIT", 1]]
SQL (0.5ms) INSERT INTO "oauth_access_grants" ("resource_owner_id", "application_id", "token", "expires_in", "redirect_uri", "created_at", "scopes") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id" [["resource_owner_id", 1], ["application_id", 11], ["token", "a6bd0459570f1e0116ca6b2cade1e60ae83ba439d3c70b750046cfffe3cc85e4"], ["expires_in", 600], ["redirect_uri", "https://3751d64e.ngrok.io/oauth/callback"], ["created_at", "2017-10-23 12:40:36.235539"], ["scopes", ""]]
(1.5ms) COMMIT
Redirected to https://3751d64e.ngrok.io/oauth/callback?code=a6bd0459570f1e0116ca6b2cade1e60ae83ba439d3c70b750046cfffe3cc85e4
Completed 302 Found in 14ms (ActiveRecord: 4.2ms)
Started GET "/oauth/callback?code=[FILTERED]" for 5.175.83.20 at 2017-10-23 13:40:36 +0100
Processing by SessionsController#oauth_call as HTML
Parameters: {"code"=>"[FILTERED]"}
Started POST "/oauth/token" for 5.175.83.20 at 2017-10-23 13:40:37 +0100
Completed 500 Internal Server Error in 60406ms (ActiveRecord: 0.0ms)
Faraday::TimeoutError (Net::ReadTimeout)
Cant for the life of me figure out why it works in irb but not in code. Here is what i do in irb
irb(main):001:0> require 'oauth2'
=> true
irb(main):002:0>
irb(main):003:0* client_id = '6067fbe8f36b4343aa297ce76348e868f9ea04b04841adb411d0885c491c1d48'
=> "6067fbe8f36b4343aa297ce76348e868f9ea04b04841adb411d0885c491c1d48"
irb(main):004:0> client_secret = '937088f4b7579b8922ad02518477da7be699958df1b1e8a85da34f2e8b4ce086'
=> "937088f4b7579b8922ad02518477da7be699958df1b1e8a85da34f2e8b4ce086"
irb(main):005:0> redirect_uri = 'https://3751d64e.ngrok.io/oauth/callback'
=> "https://3751d64e.ngrok.io/oauth/callback"
irb(main):006:0> site = 'https://3751d64e.ngrok.io'
=> "https://3751d64e.ngrok.io"
irb(main):007:0> state = 'some state'
=> "some state"
irb(main):008:0> client = OAuth2::Client.new(client_id, client_secret, :site => site)
=> #<OAuth2::Client:0x007fa61414c4b0 #id="6067fbe8f36b4343aa297ce76348e868f9ea04b04841adb411d0885c491c1d48", #secret="937088f4b7579b8922ad02518477da7be699958df1b1e8a85da34f2e8b4ce086", #site="https://3751d64e.ngrok.io", #options={:authorize_url=>"/oauth/authorize", :token_url=>"/oauth/token", :token_method=>:post, :auth_scheme=>:request_body, :connection_opts=>{}, :connection_build=>nil, :max_redirects=>5, :raise_errors=>true}>
irb(main):009:0> client.auth_code.authorize_url(:redirect_uri => redirect_uri)
=> "https://3751d64e.ngrok.io/oauth/authorize?client_id=6067fbe8f36b4343aa297ce76348e868f9ea04b04841adb411d0885c491c1d48&redirect_uri=https%3A%2F%2F3751d64e.ngrok.io%2Foauth%2Fcallback&response_type=code"
even If i put that uri into browser and it returns the access token:
{"token_type":"bearer","created_at":1508763209,"access_token":"38282cae5191923f1f358aece869e237d4d9742cdd7c918ae63104c57807a826","refresh_token":null,"expires_at":1508770409}
Again any help would be amazing!
So I found in my Dev Environment, if i stop using puma and rails server and started using POW, the issue went away. I checked if puma was running as single thread but it was running 5 threads, so not sure why this was happening.

plan id not being assigned in Devise form. Rails

I have a Rails app with 3 sign up button links on the home page.
Each has it's own plan assigned to it. Two of them go to a basic form while the third goes to a form with credit card details, handled by Stripe. The forms and Users are handled by Devise.
The plans seem to be setup correctly and are seen in the rails console however, when I go to sign up, to any of them, only the email address and password is captured, and NO plan_id is assigned.
I've noticed when previewing the form pages locally that the url at the top doesn't change to the specific form url, i.e /users/sign_up?plan=3 for example, but instead shows the form but stays on the homepage url? I'm confused because the server seems to recognise which link i'm clicking on and which plan needs to be assigned?? Please Help!!
Started GET "/users/sign_up?plan=3" for 124.149.46.152 at 2015-08-21 06:32:19 +0000
Cannot render console from 124.149.46.152! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Users::RegistrationsController#new as HTML
Parameters: {"plan"=>"3"}
Rendered devise/registrations/_paid.html.erb (8.1ms)
Rendered devise/shared/_links.html.erb (0.3ms)
Rendered devise/registrations/new.html.erb within layouts/application (11.6ms)
Completed 200 OK in 154ms (Views: 151.7ms | ActiveRecord: 0.0ms)
console User.last
=> #<User id: 7, email: "testemail1#test.com", encrypted_password: "$2a$10$.EldkZ3KUdnz4u1dvIMkXO7U6GnAnrGNYomdITKqup....", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2015-08-21 07:05:34", last_sign_in_at: "2015-08-21 07:05:34", current_sign_in_ip: "124.149.46.152", last_sign_in_ip: "124.149.46.152", created_at: "2015-08-21 07:05:34", updated_at: "2015-08-21 07:05:34", plan_id: nil, stripe_customer_token: nil>
and this is my application_controller.rb
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:name, :stripe_card_token, :email, :password, :password_confirmation }
end
end
development log
Started POST "/users" for 124.149.46.152 at 2015-08-21 07:31:57 +0000
Cannot render console from 124.149.46.152! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Users::RegistrationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"mA18/inejU2zEZiYXJq1xEtguLOEWnIV9UBozrHyXKPp2/2n9Ls7Km4+fCuZBL51EHUxSE+QJFRdbgW1fbMyew==", "user"=>{"email"=>"test10#gmail.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
[1m[35m (0.4ms)[0m begin transaction
[1m[36mUser Exists (0.2ms)[0m [1mSELECT 1 AS one FROM "users" WHERE "users"."email" = 'test10#gmail.com' LIMIT 1[0m
[1m[35mSQL (0.6ms)[0m INSERT INTO "users" ("email", "encrypted_password", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["email", "test10#gmail.com"], ["encrypted_password", "$2a$10$4cjIpysvXyckg0j4Kxzx9eqR9vVzqcmaQZPLdCC0X2jEik2MG/KrK"], ["created_at", "2015-08-21 07:31:57.381867"], ["updated_at", "2015-08-21 07:31:57.381867"]]
[1m[36m (19.3ms)[0m [1mcommit transaction[0m
[1m[35m (0.2ms)[0m begin transaction
[1m[36mSQL (0.5ms)[0m [1mUPDATE "users" SET "last_sign_in_at" = ?, "current_sign_in_at" = ?, "last_sign_in_ip" = ?, "current_sign_in_ip" = ?, "sign_in_count" = ?, "updated_at" = ? WHERE "users"."id" = ?[0m [["last_sign_in_at", "2015-08-21 07:31:57.405089"], ["current_sign_in_at", "2015-08-21 07:31:57.405089"], ["last_sign_in_ip", "124.149.46.152"], ["current_sign_in_ip", "124.149.46.152"], ["sign_in_count", 1], ["updated_at", "2015-08-21 07:31:57.406791"], ["id", 8]]
[1m[35m (19.7ms)[0m commit transaction
Redirected to https://socialplayground-portal-runpixelrun.c9.io/
Completed 302 Found in 136ms (ActiveRecord: 40.9ms)
Started GET "/" for 124.149.46.152 at 2015-08-21 07:31:57 +0000
Cannot render console from 124.149.46.152! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by PagesController#home as HTML
[1m[36mPlan Load (0.4ms)[0m [1mSELECT "plans".* FROM "plans" WHERE "plans"."id" = ? LIMIT 1[0m [["id", 1]]
[1m[35mPlan Load (0.2ms)[0m SELECT "plans".* FROM "plans" WHERE "plans"."id" = ? LIMIT 1 [["id", 2]]
[1m[36mPlan Load (0.2ms)[0m [1mSELECT "plans".* FROM "plans" WHERE "plans"."id" = ? LIMIT 1[0m [["id", 3]]
Rendered pages/home.html.erb within layouts/application (1.0ms)
[1m[35mUser Load (0.4ms)[0m SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 8]]
Completed 200 OK in 210ms (Views: 207.3ms | ActiveRecord: 1.2ms)
[1m[36mUser Load (0.7ms)[0m [1mSELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1[0m
Started DELETE "/users/sign_out" for 124.149.46.152 at 2015-08-21 07:35:08 +0000
Cannot render console from 124.149.46.152! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Devise::SessionsController#destroy as HTML
Parameters: {"authenticity_token"=>"p1LtsYqgP4SPYiiAh8/l1/XPNc888HMVob3thu5Y093WhGzoV8WJ41JNzDNCUe5mrtq8NPc6JVQJk4D9Ihm9BQ=="}
[1m[36mUser Load (0.2ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1[0m [["id", 8]]
[1m[35m (0.1ms)[0m begin transaction
[1m[36m (0.1ms)[0m [1mcommit transaction[0m
Redirected to https://socialplayground-portal-runpixelrun.c9.io/
Completed 302 Found in 10ms (ActiveRecord: 0.4ms)
Started GET "/" for 124.149.46.152 at 2015-08-21 07:35:08 +0000
Cannot render console from 124.149.46.152! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by PagesController#home as HTML
[1m[35mPlan Load (0.2ms)[0m SELECT "plans".* FROM "plans" WHERE "plans"."id" = ? LIMIT 1 [["id", 1]]
[1m[36mPlan Load (0.1ms)[0m [1mSELECT "plans".* FROM "plans" WHERE "plans"."id" = ? LIMIT 1[0m [["id", 2]]
[1m[35mPlan Load (0.1ms)[0m SELECT "plans".* FROM "plans" WHERE "plans"."id" = ? LIMIT 1 [["id", 3]]
Rendered pages/home.html.erb within layouts/application (0.8ms)
Completed 200 OK in 206ms (Views: 203.3ms | ActiveRecord: 0.5ms)
/registrations_controller.rb
class Users::RegistrationsController < Devise::RegistrationsController
before_filter :select_plan, only: :new
def create
super do |resource|
if params[:plan]
resource.plan_id = params[:plan]
if resource.plan_id == 3
resource.save_with_payment
else
resource.save
end
end
end
end
private
def select_plan
unless params[:plan] && (params[:plan] == '1' || params[:plan] == '2' || params[:plan] == '3')
flash[:notice] = "Please select a valid membership plan."
redirect_to root_url
end
end
end
To allow plan_id to be save you need to add it in devise signup parameters. You can do this by adding following into your application controller
before_filter :configure_permitted_parameters, if: :devise_controller?
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :password_confirmation, :plan_id) }
end

Resources