Stack Level Too Deep: Spree Admin - Product Images - ruby-on-rails

I'm getting a Stack Level Too Deep error in my Production environment for spree 2.3.0.
It occurs when I try to go to the product images index page in the Admin panel. This error is not happening in Development, only production on Ninefold. The error does not occur when I run the app locally in Production mode. I can seem to trace what is causing it. I have not changed any of the default core functionality in Spree related to Product Images. The images render fine on the front-end.
I'm using paperclip and aws. At one point there was no error on production. However, I've check all my commits and cant pinpoint what changed that is causing this issue. I've added other gems, but none of the gems conflict with the paperclip gems or its dependency, which was my my guess at what might be causing this.
here is the production log error.
+0000
I, [2015-01-11T22:02:28.691119 #26116] INFO -- : Processing by Spree::Admin::ImagesController#index as HTML
I, [2015-01-11T22:02:28.691252 #26116] INFO -- : Parameters: {"product_id"=>"black-string-tie-halter-top-with-printed-neck-binding"}
D, [2015-01-11T22:02:28.693443 #26116] DEBUG -- : Cache read: spree/app_configuration/redirect_https_to_http
D, [2015-01-11T22:02:28.693920 #26116] DEBUG -- : Cache read: spree/backend_configuration/locale
D, [2015-01-11T22:02:28.695806 #26116] DEBUG -- : [1m[36mSpree::Preference Load (0.7ms)[0m [1mSELECT "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = 'spree/backend_configuration/locale' LIMIT 1[0m
D, [2015-01-11T22:02:28.695979 #26116] DEBUG -- : Cache write: spree/backend_configuration/locale
D, [2015-01-11T22:02:28.696566 #26116] DEBUG -- : Cache read: spree/app_configuration/allow_ssl_in_production
D, [2015-01-11T22:02:28.696881 #26116] DEBUG -- : Cache read: spree/app_configuration/check_for_spree_alerts
D, [2015-01-11T22:02:28.697171 #26116] DEBUG -- : Cache read: spree/app_configuration/last_check_for_spree_alerts
D, [2015-01-11T22:02:28.699099 #26116] DEBUG -- : [1m[35mSpree::User Load (0.5ms)[0m SELECT "spree_users".* FROM "spree_users" WHERE "spree_users"."id" = 1 ORDER BY "spree_users"."id" ASC LIMIT 1
D, [2015-01-11T22:02:28.702026 #26116] DEBUG -- : [1m[36m (0.5ms)[0m [1mSELECT COUNT(*) FROM "spree_roles" INNER JOIN "spree_roles_users" ON "spree_roles"."id" = "spree_roles_users"."role_id" WHERE "spree_roles_users"."user_id" = $1 AND "spree_roles"."name" = 'admin'[0m [["user_id", 1]]
I, [2015-01-11T22:02:28.706068 #26116] INFO -- : Completed 500 Internal Server Error in 15ms
F, [2015-01-11T22:02:28.706732 #26116] FATAL -- :
SystemStackError (stack level too deep):
vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:629
Any help would be greatly appreciated!
update - Full Stack Trace in Production Environment:
SystemStackError in Spree::Admin::ImagesController#index
stack level too deep
Rails.root: /var/www/apps/11829/releases/dbeebbeebaf8ac5fa580e0fd192ad9fc06e7ce4b
Application Trace | Framework Trace | Full Trace
vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:629

So after going through all the gems I installed I finally found the issue.
It was an alias_method in the Spree::Admin::ImagesController decorator that caused the Stack Level Too Deep error.

Related

Rails redirect loop in production, everything is fine in development

I am running into an issue with Rails where in production it generates an error in the log file, but nothing in the development mode:
I, [2019-10-16T12:02:16.953954 #11866] INFO -- : [e5d5e3b6-2a9c-4d27-b1f3-2d5a1b76ce5a] Started GET "/" for 155.186.157.103 at 2019-10-16 12:02:16 -0500
I, [2019-10-16T12:02:16.955549 #11866] INFO -- : [e5d5e3b6-2a9c-4d27-b1f3-2d5a1b76ce5a] Processing by Devise::SessionsController#new as HTML
I, [2019-10-16T12:02:16.956733 #11866] INFO -- : [e5d5e3b6-2a9c-4d27-b1f3-2d5a1b76ce5a] Rendering devise/sessions/new.html.erb within layouts/application
I, [2019-10-16T12:02:16.958443 #11866] INFO -- : [e5d5e3b6-2a9c-4d27-b1f3-2d5a1b76ce5a] Rendered devise/shared/_links.html.erb (0.3ms)
I, [2019-10-16T12:02:16.958796 #11866] INFO -- : [e5d5e3b6-2a9c-4d27-b1f3-2d5a1b76ce5a] Rendered devise/sessions/new.html.erb within layouts/application (2.0ms)
E, [2019-10-16T12:02:29.471353 #11866] ERROR -- : [2c2037b2-3b07-495d-b936-778c070e1ad7] undefined method `[]' for nil:NilClass
I, [2019-10-16T12:02:29.473147 #11866] INFO -- : [2c2037b2-3b07-495d-b936-778c070e1ad7] Redirected to [redacted-for-stackoverflow]
I, [2019-10-16T12:02:29.473928 #11866] INFO -- : [2c2037b2-3b07-495d-b936-778c070e1ad7] Completed 302 Found in 22438ms (ActiveRecord: 0.0ms)
E, [2019-10-16T12:02:39.225917 #11866] ERROR -- : [e5d5e3b6-2a9c-4d27-b1f3-2d5a1b76ce5a] undefined method `[]' for nil:NilClass
I, [2019-10-16T12:02:39.227867 #11866] INFO -- : [e5d5e3b6-2a9c-4d27-b1f3-2d5a1b76ce5a] Redirected to [redacted-for-stackoverflow]
I, [2019-10-16T12:02:39.229075 #11866] INFO -- : [e5d5e3b6-2a9c-4d27-b1f3-2d5a1b76ce5a] Completed 302 Found in 22273ms (ActiveRecord: 0.0ms)
However, if I load development mode, the login page comes up just fine. I can't figure out what could possibly be causing this error since the error isn't descriptive as to where the issue resides.
I ran across another post to temporarily change config.consider_all_requests_local = false to config.consider_all_requests_local = true in config/environments/production.rb but that hasn't changed anything. No additional information is being provided.
How can I trace down this issue that's only occurring in production?
I have literally replaced everything in layouts/application.html.erb to try pin pointing where the issue is, but no luck. I noticed that rake assets:precompile fails as well with the same error, so perhaps it has some kind of issue in there.
Can you show the contents of devise/sessions/new.html.erb
It seems you are attempting to access a hash by key e.g. my_hash[:my_key] but my_hash in nil
After troubleshooting this some more, it finally boiled down to a stylesheet ending in .css rather than .css.scss since it was loading some rails stuff. I only came across this because rake assets:precompile kept failing.

Recaptcha rails 5 error

I am having an error with recaptcha recognizing my keys in secrets.yml in production. In development, everything works fine!
I was able to upload successfully my site using capistrano and nginx, I placed the recaptcha keys in secrets.yml but I get the following error in rails logs.
[70624ace-d7c2-41d4-a312-81e558237559] app/views/contacts/_new.html.erb:1:in `_app_views_contacts__new_html_erb___113748072819217608_34958780'
[70624ace-d7c2-41d4-a312-81e558237559] app/views/welcome/index.html.erb:97:in `_app_views_welcome_index_html_erb__2483501284442413835_31069860'
I, [2018-02-13T15:06:06.655443 #23369] INFO -- : [1abb6e09-8ebd-41a3-ad0c-ea88749d804f] Started GET "/" for 66.249.70.22 at 2018-02-13 15:06:06 +0000
I, [2018-02-13T15:06:06.656262 #23369] INFO -- : [1abb6e09-8ebd-41a3-ad0c-ea88749d804f] Processing by WelcomeController#index as HTML
I, [2018-02-13T15:06:06.657082 #23369] INFO -- : [1abb6e09-8ebd-41a3-ad0c-ea88749d804f] Rendering welcome/index.html.erb within layouts/application
I, [2018-02-13T15:06:06.666156 #23369] INFO -- : [1abb6e09-8ebd-41a3-ad0c-ea88749d804f] Rendered contacts/_new.html.erb (8.3ms)
I, [2018-02-13T15:06:06.666316 #23369] INFO -- : [1abb6e09-8ebd-41a3-ad0c-ea88749d804f] Rendered welcome/index.html.erb within layouts/application (9.1ms)
I, [2018-02-13T15:06:06.666485 #23369] INFO -- : [1abb6e09-8ebd-41a3-ad0c-ea88749d804f] Completed 401 Unauthorized in 10ms
F, [2018-02-13T15:06:06.667938 #23369] FATAL -- : [1abb6e09-8ebd-41a3-ad0c-ea88749d804f]
F, [2018-02-13T15:06:06.668014 #23369] FATAL -- : [1abb6e09-8ebd-41a3-ad0c-ea88749d804f] ActionView::Template::Error (No site key specified.):
F, [2018-02-13T15:06:06.668157 #23369] FATAL -- : [1abb6e09-8ebd-41a3-ad0c-ea88749d804f] 9:
I am trying to follow this tutorial https://github.com/ambethia/recaptcha, but it does not provide much detail about placing the keys in production.
I have tried many things, like adding export in front of the keys, placing them in different files, and checking secrets.yml for any syntax error. I have also made sure that I am using RECAPTHCA_SITE_KEY instead of RECAPTCHA_PUBLIC_KEY.
Also, I have placed my domain in recaptcha's site.
I would appreciate if you could help me solve the problem as well as provide some explanation of why I was having the error.
This is my secrets.yml in production:
production:
secret_key_base: ...SECRET_KEY...
RECAPTCHA_SITE_KEY: "...SITE_KEY..."
RECAPTCHA_PRIVATE_KEY: "...PRIVATE_KEY..."
Thanks!
You need to configure recaptcha to pull the keys from your secrets.yml by adding an initializer file, config/initializers/recaptcha.rb:
# config/initializers/recaptcha.rb
Recaptcha.configure do |config|
config.site_key = Rails.application.secrets[:RECAPTCHA_SITE_KEY]
config.secret_key = Rails.application.secrets[:RECAPTCHA_PRIVATE_KEY]
# Uncomment the following line if you are using a proxy server:
# config.proxy = 'http://myproxy.com.au:8080'
end

Web application could not be started Capistrano Nginx Passanger DigitalOcean

I am trying to deploy my rails app to DigitalOcean. It is my first time to deploy rails app.
So I followed https://gorails.com/deploy/ubuntu/16.04 this tutorial. I did everything except the database.yml.example part since my repo is private. I use RVM for ruby.
When i go my IP address on my browser, I get this page -> http://i.hizliresim.com/BvBYkp.png
I have been trying to solve this for 2 days and I am about to lose my mind because I can not find any solution.
Here is my production.log file.
D, [2017-01-29T07:34:02.835118 #16679] DEBUG -- : ^[[1m^[[35m (0.3ms)^[[0m ^[[1m^[[34mSELECT pg_try_advisory_lock(2623970102560787400);^[[0m
D, [2017-01-29T07:34:02.847575 #16679] DEBUG -- : ^[[1m^[[36mActiveRecord::SchemaMigration Load (0.8ms)^[[0m ^[[1m^[[34mSELECT "schema_migrations".* FROM "schema_migrations"^[[0m
D, [2017-01-29T07:34:02.867835 #16679] DEBUG -- : ^[[1m^[[36mActiveRecord::InternalMetadata Load (0.5ms)^[[0m ^[[1m^[[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2^[[0m [["key", :environment], ["LIMIT", 1]]
D, [2017-01-29T07:34:02.872345 #16679] DEBUG -- : ^[[1m^[[35m (0.1ms)^[[0m ^[[1m^[[35mBEGIN^[[0m
D, [2017-01-29T07:34:02.873998 #16679] DEBUG -- : ^[[1m^[[35m (0.2ms)^[[0m ^[[1m^[[35mCOMMIT^[[0m
D, [2017-01-29T07:34:02.874562 #16679] DEBUG -- : ^[[1m^[[35m (0.3ms)^[[0m ^[[1m^[[34mSELECT pg_advisory_unlock(2623970102560787400)^[[0m
If i forgot to add some logs, please tell me so I can add. Thanks
Okay, I have found the solution.
In the /etc/nginx/passenger.conf I thought passenger_ruby part should be /home/deploy/.rvm/rubies/ruby-2.3.3/bin/ruby Since I downloaded ruby there. But this is totally wrong. Original conf should be like this -> /home/deploy/.rvm/wrappers/ruby-2.3.3/ruby;

Braintree::ConfigurationError (Braintree::Configuration.merchant_id needs to be set)

I only get that error when I run my app in production(Heroku). Locally run ok, I already tested some transactions and it works. I use a Braintree sandbox account
To be specific I get the following error:
2015-05-18T19:07:53.077006+00:00 app[web.1]: Started GET "/transactions/new" for 160.9.0.125 at 2015-05-18 19:07:53 +0000
2015-05-18T19:07:53.093436+00:00 app[web.1]: User Load (1.9ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
2015-05-18T19:07:53.095900+00:00 app[web.1]: Braintree::ConfigurationError (Braintree::Configuration.merchant_id needs to be set):
2015-05-18T19:07:53.095898+00:00 app[web.1]:
2015-05-18T19:07:53.095902+00:00 app[web.1]: app/controllers/transactions_controller.rb:54:in `generate_new_client_token'
2015-05-18T19:07:53.095903+00:00 app[web.1]: app/controllers/transactions_controller.rb:9:in `new'
2015-05-18T19:07:53.095905+00:00 app[web.1]:
2015-05-18T19:07:53.095906+00:00 app[web.1]:
2015-05-18T19:07:53.089739+00:00 app[web.1]: Processing by TransactionsController#new as HTML
2015-05-18T19:07:53.094330+00:00 app[web.1]: Completed 500 Internal Server Error in 4ms
So my question is If I can use a braintree sandbox account in production or I need to switch to a production account in braintree? Is sandbox causing the error?
config/initializers/braintree.rb
Braintree::Configuration.environment = :sandbox
Braintree::Configuration.logger = Logger.new('log/braintree.log')
Braintree::Configuration.merchant_id = ENV['BRAINTREE_MERCHANT_ID']
Braintree::Configuration.public_key = ENV['BRAINTREE_PUBLIC_KEY']
Braintree::Configuration.private_key = ENV['BRAINTREE_PRIVATE_KEY']
config/application.yml
# Braintree configuration keys
BRAINTREE_MERCHANT_ID: 'XXXXXXXXXXXX'
BRAINTREE_PUBLIC_KEY: 'XXXXXXXXXXXXXX'
BRAINTREE_PRIVATE_KEY: 'XXXXXXXXXXXXXXXXXXX'
The error was with Figaro gem that I am using which do that automatically using ENV and application.yml. I run "rake figaro:heroku[intense-harbor-8486]" in my console and everything running ok. I didn't know that i needed to do that since all gems install in heroku server when I push my app –

Rails 3.1rc4 asset pipeline broke after Ruby update? How to re-activate/configure it?

Somehow this is related but I'm not sure how/why?
Just upgraded from Ruby 1.9.2-p180 to 1.9.2-p290 via RVM's rvm upgrade command...and now my asset pipeline is 'broken'.
During rvm upgrade ... I noticed a bunch of errors for each gemset along lines of:
ERROR: Error running 'rvm gemset pristine' under ,
please read /Users/meltemi/.rvm/log//gemset.pristine.log
I let upgrade continue as there was not much interesting in the gemset.pristine.log... besides, /Users/meltemi/.rvm/log//gemset.pristine.log doesn't (can't?) exist in that exact path? two consecutive '//' in a pathname? Anyway...
Testing a small app and though it launches and appears to run it is not loading any assets (images, css, etc.). Development log has many Not Found errors (see below) about these missing assets even though they exist within app/assets/images and app/assets/stylesheets, etc... ?
Anyone know what's happening here? Seems like pipeline has broken down somehow... As if Rails no longer knows to look for assets in app/assets, perhaps? How can I test/verify/fix/re-activate this 'pipeline'?
$ rails s
=> Booting WEBrick
=> Rails 3.1.0.rc4 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-07-25 23:11:38] INFO WEBrick 1.3.1
[2011-07-25 23:11:38] INFO ruby 1.9.2 (2011-07-09) [x86_64-darwin10.8.0]
[2011-07-25 23:11:38] INFO WEBrick::HTTPServer#start: pid=74881 port=3000
Started GET "/" for 127.0.0.1 at 2011-07-25 23:11:43 -0700
Processing by PostsController#index as HTML
Post Load (0.2ms) SELECT "posts".* FROM "posts" ORDER BY posts.created_at DESC
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Photo Load (0.3ms) SELECT "photos".* FROM "photos" WHERE "photos"."post_id" = 6
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Photo Load (0.2ms) SELECT "photos".* FROM "photos" WHERE "photos"."post_id" = 5
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Photo Load (0.2ms) SELECT "photos".* FROM "photos" WHERE "photos"."post_id" = 4
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Photo Load (0.2ms) SELECT "photos".* FROM "photos" WHERE "photos"."post_id" = 2
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Photo Load (0.2ms) SELECT "photos".* FROM "photos" WHERE "photos"."post_id" = 1
Rendered posts/index.html.haml within layouts/application (3016.4ms)
Rendered layouts/_header.html.haml (9.7ms)
Completed 200 OK in 3143ms (Views: 3138.2ms | ActiveRecord: 2.9ms)
Started GET "/assets/application.css" for 127.0.0.1 at 2011-07-25 23:11:47 -0700
Served asset /application.css - 404 Not Found (1ms)
ActionController::RoutingError (No route matches [GET] "/assets/application.css"):
Rendered /Users/meltemi/.rvm/gems/ruby-1.9.2-p290#rails3/gems/actionpack-3.1.0.rc4/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.2ms)
Started GET "/assets/application.js" for 127.0.0.1 at 2011-07-25 23:11:47 -0700
Served asset /application.js - 404 Not Found (0ms)
ActionController::RoutingError (No route matches [GET] "/assets/application.js"):
Rendered /Users/meltemi/.rvm/gems/ruby-1.9.2-p290#rails3/gems/actionpack-3.1.0.rc4/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.8ms)
Started GET "/assets/racer-outline.png" for 127.0.0.1 at 2011-07-25 23:11:48 -0700
Served asset /racer-outline.png - 404 Not Found (0ms)
ActionController::RoutingError (No route matches [GET] "/assets/racer-outline.png"):
Rendered /Users/meltemi/.rvm/gems/ruby-1.9.2-p290#rails3/gems/actionpack-3.1.0.rc4/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (3.2ms)
Started GET "/assets/ray.png" for 127.0.0.1 at 2011-07-25 23:11:48 -0700
Served asset /pogo.png - 404 Not Found (0ms)
ActionController::RoutingError (No route matches [GET] "/assets/ray.png"):
Rendered /Users/meltemi/.rvm/gems/ruby-1.9.2-p290#rails3/gems/actionpack-3.1.0.rc4/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.2ms)
It seems that version 2.0.0.beta.11 of sprockets broke the assets pipeline. Putting
gem 'sprockets', '= 2.0.0.beta.10'
into your Gemfile seems to fix the problem (it worked for me). Rails seems to automatically use the most recent version of the beta for whatever reason so if you just started your project recently or updated all your gems it probably broke it.
Note that this info isn't mine originally, I got the fix from http://groups.google.com/group/rubyonrails-core/browse_thread/thread/59d8c7813b4d1bbe?pli=1
He explains the problem for ver. 2.0.0.beta.11 but I was using ver. 2.0.0.beta.12 with the same results so it seems that they haven't fixed it yet.
EDIT: It seems that upgrading your rails to 3.1.rc5 also fixes the problem
I ended up just blowing out the whole problematic gemset and starting anew. Lesson learned:
Don't trust rvm upgrade. Install the new Ruby w/in RVM. Then manually rebuild (or bundle install) your gemsets.

Resources