Vue with Rails (webpacker) Error: "Cannot GET /" - ruby-on-rails

I made new project with Rails and Vue using webpacker. Firstly I got strange error
Cannot read property 'compile' of undefined
So I hit yarn upgrade webpack-dev-server --latest which was the correct answer and helped me but then when I hit: ./bin/webpack-dev-server my webpack dev server starts and all looks fine but at http://localhost:3035/ I am getting the "Cannot GET /" message.
JS console: Failed to load resource: the server responded with a status of 404
I also tried to reinstall webpacker...

When running your Rails application locally you'll need to start both the rails server and the webpack-dev-server. I typically use foreman with a simple Procfile, although you can also start both of these by hand.
# Procfile
server: bin/rails server
assets: bin/webpack-dev-server
Then you can run the Procfile and startup both servers with: foreman start
The webpack-dev-server port (3035) is not the port you'll be connecting to for seeing your application. Start up both servers and go to localhost:3000 and you'll see your rails application root path page (or default rails page if you dont have routes yet).
One thing to note, if you're using Foreman to start your servers it will default your rails port to 5000 instead of 3000. You can configure this either in the Procfile or when you call foreman if you want different behavior.

Related

How to configure Solr standalone in Production server with Rails application using sunspot gem?

I'm looking to deploy solr-8 in production as standalone mode with Ruby on Rails application. While running bundle exec rake sunspot:solr:reindex getting this error
RSolr::Error::Http - 500 Internal Server Error
Any help would be appreciated!
using gem sunspot in development and is working fine with standalone solr-8 on local machine.
Solr is running in cloud mode. Please share the configuration which is used to talk to solr and rails for index
It's really straight forward setup but took long time for me to resolve.
In standalone mode it is bit tricky to communicate with rails
we need to copy schema.xml and solrconfig.xml to server/solr/your-core/conf/
as Solr-8 have some deprecation warning. Please carefully read warnings.
Once you copied files restart solr and run
rake sunspot:solr:reindex

Why does my heroku app only work when rails server is running locally?

Sorry, this is my first time deploying my site on Heroku. The main elements of website does run, but none of my fetch requests are working. So, none of the data from my Rails backend is rendering. I've been receiving this in my console whenever the site is supposed to make a fetch request (to localhost:3000) => "Failed to load resource: net::ERR_CONNECTION_REFUSED"
Should I not be trying to fetch from localhost when my site is deployed on heroku?
I've tried creating a Procfile, updating my production and development environments, etc.
web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-production}

Bundler won't find puma when deploying Rails 5 app

Just FYI, this is the first time I'm deploying something on a production server. I went through this guide as my server is also hosted on DO.
The environment is pretty much the same - I'm using Ubuntu 14.04, Ruby 2.3.3 (rbenv) and rails 5.
I followed everything step by step and I have gotten no error, however, now I'm getting a 502 bad gateway when accessing my public IP.
I have noticed that for some reason after starting puma manager (sudo start puma-manager), the directory "shared/sockets/puma.sock" is not getting created.
When I start puma manually by using -> RACK_ENV=production bundle exec puma -C config/puma.rb from my app directory, I get the following error:
bundler: failed to load command: puma (/root/.rbenv/versions/2.3.3/bin/puma)
Errno::ENOENT: No such file or directory - connect(2) for /root/belooga/shared/sockets/puma.sock
Any idea of what I might be doing wrong? Should you need to see any file, please let me know and I'll provide anything that might be needed.
Cheers!
EDIT:
I have double-checked all the paths in:
myapp/config/puma.rb
/etc/puma.conf
/etc/nginx/sites-available/default
... the directory "shared/sockets/puma.sock" is not getting created.
Here is your problem, create the directory before you start the puma server.

The localhost page isn’t working ruby rails puma osx

I have been working on a rails app for months and then, all of a sudden the pumas server does not work on my laptop. I've tried different older branches (in case I changed something) I've uninstalled and reinstalled ruby. Nope. It DOES work if I do a fresh pull and load it on my desktop, so it seems to be something on my laptop? I am really lost.
Here's what I've done already:
Restarted the computer
reinstalled ruby
Tried puma
Tried rails s
Tried different branches to see if something I did yesterday somehow broke it
reinstalled gems
The error is:
The localhost page isn’t working
localhost didn’t send any data.
However, right before it was running this error, it ran a Request time out error, if that matters.
What I really don't understand is why it's only happening on one computer.
I am running Ruby 2.3.0 and rails 4.2.6
UPDATE
It DOES running rails server and not puma.
The problem is, I'm using foreman to start sidekiq with my server, and that's how I debug sidekiq queues. Strangely, sidekiq still works, but I can't access the localhost page.
This is my procfile:
web: bundle exec puma -C config/puma.rb
worker: bundle exec sidekiq -c 2 -q default -q mailers
Again, I haven't changed anything with puma and rails s works fine.

Running Sidekiq in Rails app using AWS Elasticache

I am trying to configure Sidekiq in a Rails 4.1.4 application that connects to an AWS Elasticache Node running Redis.
I set up my Redis server, and followed the directions in this AWS Guide:
http://docs.aws.amazon.com/opsworks/latest/userguide/other-services-redis-cluster.html
And my Redis server was running properly and my app server could connect properly.
I followed these directions to set up Sidekiq to run on the external worker:
https://github.com/mperham/sidekiq/wiki/Advanced-Options
Whenever I visited my app server at the /sidekiq url to view the Sidekiq panel, I kept getting the error on screen saying "Internal Server Error".
My Unicorn error logs do not contain any relevant information, so I am not sure how to get this working. AWS support did not have any answers either.
Any information would be greatly appreciated. Thanks!
This problem is normally seen when assets are not compiled or are not configured to be served from your environment. Start your app/sidekiq in production mode (or whatever environment this is referring to) after changing the production config to point to your local resources (redis+db) and see if the pages are able to load then.
RAILS_ENV=production bundle exec unicorn
RAILS_ENV=production bundle exec sidekiq -c config/sidekiq.yml

Resources