Spree error 500 - ruby-on-rails

Need some help here.
I have deployed spree (0.70.3) on slicehost (ubuntu, ruby1.8.7, Rails
3.1.3), installed the spree gem, loaded in the sample data
successfully following the steps on spree startup manual and I am
using passenger (it works on localhost:3000). When I upload to my
server, however, instead of seeing the spree interface, I am getting
an error message. From the production.log:
Processing by HomeController#index as HTML Completed 500 Internal
Server Error in 22ms ActiveRecord::StatementInvalid (Could not find
table 'product_groups'):
Any suggestions how I can get this to work?
Website: http://www.nutxboutique.com

production.log is the rails log. It appears your problem is occurring before rails completes loading. If you're using apache, check/post the apache logs, it might have more clues as to what's going on.

Related

Rails returns HTTP 500 for every page with no error log after bundle install

Today I tried to install a gem using bundler. It complained about super-user privileges so I ran it to install to vendor/bundle, and then all of a sudden every page in my app returns HTTP 500 for seemingly no reason. I re-ran bundler to install globally, and that didn't solve the problem.
In typical rails fashion, it just exits with the 500 error page without printing anything to the logs. Routing is functioning normally, the console says it renders the appropriate view, and active record seems to be working as normal, but after all of that it just shows an error page. No errors on the console or in logs/.
I'm not sure why bundler would cause this issue but I'm completely out of ideas. I've done a good bit of googling but all of the other similar situations I've found were because of a misconfigured model or database, which I know with certainty isn't the case. If anyone more familiar with Rails than me could give me a place to start I'd be very grateful.
Update: Running bundler doctor fails b/c the directory /opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bundler doesn't exist - looking for issues related to this.
Solved; ultimately this was because I forgot to delete an old requirement in application.js. It still seems absolutely ludicrous to me that rails would exit 500 without an error message with no way to access more verbose debug logs

Rails on EC2 - Puma responds, but page never loads on browser

Firstly, cheers! This is my first post here on Stack Overflow, I'll try not to do anything silly :). I've spent the last 3 days banging my head against this issue and googleing away, but never really found a solution, however basic it may be.
I've set up a fresh EC2 instance (running Ubuntu 16.04) and created a new Rails (v 5.1.6) app with a simple scaffold:
rails new test_app
cd test_app
At this point, Rails complained that I had to install the 'listen' gem, which I did (v 3.1.5). I then proceeded as follows:
rails g scaffold article title:string
rails db:create
rails db:migrate
So far so good. I then went on to configure AWS's security groups and properly allow TCP connections through port 3000. I'm currently using Puma (v 3.7) as a server.
Here's whats bugging me: I then ran
rails server
and tried to connect to my EC2 through Chrome on port 3000. Turns out that I was able to get to the usual "You're on Rails" page, no problem, but when I tried to get to any other pages, say /articles or /articles/new, I got a positive response from the server in the console:
Started GET "/articles"
Processing by ArticlesController#index as HTML
Rendering articles/index.html.erb within layouts/application
Article Load (0.7ms) SELECT "articles".* FROM "articles"
Rendered articles/index.html.erb within layouts/application (47.3ms)
Completed 200 OK in 3912ms (Views: 3807.5ms | ActiveRecord: 1.5ms)
But the browser keeps waiting forever for a response. I also tried accessing the URL through curl and got no response as well. I'd appreciate if anyone could let me know how stupid a mistake I'm making here.
Thanks,
Márcio
Firstly, cheers you explained your problem very well
when you deploying your app on EC2 then this isn't the right way to do but still it should give you response in browser. Please make sure your port 3000 isn't blocked. Go to network interface -> select your instance carefully -> in front of Security groups check your inbound rules and make sure port 3000 is open
Above explanation is just to answer whatever you are trying to do. Although this should not be the proper way. Proper way should (in short ) be running your ruby on rails application with a rack server (puma, thin, etc) behind a web server Apache or Nginx .

Spree - Timeout when trying to access backend

Since this afternoon, access to the backend of my spree shop is suddenly unavailable. When I try to visit any page in the backend (/admin/users, /admin/orders, etc) the page just loads for a long time, until it times out and I get the generic error page.
When I look into the logs I always see either :
Processing by Spree::Admin::OrdersController#index as HTML
Completed 500 Internal Server Error in 127259ms
** [Airbrake] Success: Net::HTTPOK
Errno::ETIMEDOUT (Connection timed out - connect(2)):
app/middleware/flash_session_cookie_middleware.rb:18:in `call'
or
Processing by Spree::Admin::OrdersController#index as HTML
Completed 500 Internal Server Error in 127520ms
** [Airbrake] Success: Net::HTTPOK
SocketError (getaddrinfo: Name or service not known):
app/middleware/flash_session_cookie_middleware.rb:17:in `call'
This started happening after the last deployment to production, which only changed images and stylesheets. I can't reproduce the error locally, despite having the same code and an exact copy of the production database.
I'm using Spree version 2.0.3
Run Spree::Config[:check_for_spree_alerts] = false in your console to fix this. You may also want to add this line to your initializers/spree.rb to ensure check_for_spree_alerts is not re-enabled in the future.
This is happening because the Spree Alerts website has been discontinued. See: https://github.com/spree/spree/pull/6516
To be specific, this is happening because when logging into the backend, Spree 2.0.x checks for any alerts from the Spree website here https://github.com/spree/spree/blob/2-0-stable/backend/app/controllers/spree/admin/base_controller.rb#L39 which then calls alert.rb:14 :
HTTParty.get('http://alerts.spreecommerce.com/alerts.json', query: params).parsed_response
At the moment, alerts.spreecommerce.com has been discontinued and is timing out, which explains the errors you're receiving.
The Spree Alerts code has been removed as of Spree 2.3, so you could also upgrade to that version to resolve this issue.

How can I debug my Rails application which encountered an internal server error?

I am using Rails 4.1 and Ruby 2.1.1 on Ubuntu.
My application is running just fine on the local development environment. When I moved everything to the production environment server, and tried the application URL, I got the following:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
The log file (production.log) has in it something about the migrations, but nothing else.
Where do I get started trying to figure out what this is about?
From original poster:
I followed the instructions and set up an environment variable for the secret_key. It turns out Rails 4.1 cannot read it and this seems to be a known issue. So, I had to put the key directly into secrets.yml and this solved the problem

Having problems deploying a Rails app to Fedora 8 w/Passenger

I'm using Capistrano and have everything configured. The weird issue I have is that before, I got a nice Passenger error saying what was wrong (I hadn't fully uploaded my vendor/rails directory). After I do that, however, I'm now getting the general Rails We're sorry, but something went wrong 500 error instead of the Passenger error page. My production log shows nothing (only that the log was created). Apache logs show nothing. I don't get why I'm no longer seeing the Passenger error that tells me exactly what is wrong; fixing the error Passenger was complaining about shouldn't prevent it from getting there, should it?
Can anyone help me?
FYI I'm running several PHP-based applications on the same server, with the rails app set as a subdomain (e.g. railsapp.mydomain.com). The full stack is:
Fedora Core 8
Apache 2.2.9
MySQL 5.0.45
Rails 2.3.4
Passenger 2.2.5
You have two issues at hand:
You're log file isn't writable by Passenger. Passengers runs as Apache. So make sure the webserver has the correct rights to write to the log/ directory.
You are probably missing a gem, database or configuration file. Can you start a console session?
./script/console production

Resources