“rails generate controller” is not creating a controller - ruby-on-rails

I am following the Rails guide http://guides.rubyonrails.org/getting_started.html and when I ran this command: rails generate controller Welcome index I couldn't find the generated files. So I ran the rails server and noticed that it says it's loading the new generated files in /Users/joseph/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/templates/rails/welcome/index.html.erb
Weird? What's going on?
~/RubymineProjects/blog
% rails server
=> Booting Puma
=> Rails 5.0.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.5.0 (ruby 2.3.0-p0), codename: Amateur Raccoon Rocketry
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
Started GET "/" for ::1 at 2016-07-19 20:38:04 -0700
Processing by Rails::WelcomeController#index as HTML
Parameters: {"internal"=>true}
Rendering /Users/joseph/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/templates/rails/welcome/index.html.erb
Rendered /Users/joseph/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/templates/rails/welcome/index.html.erb (5.3ms)
Completed 200 OK in 23ms (Views: 11.6ms | ActiveRecord: 0.0ms)

Related

My rails application(in local) suddenly stop responding to requests

I have been working on a rails application for the past four months. Suddenly one-day puma server stops responding to the requests.
Here is what I see in the terminal:
$ rails s
=> Booting Puma
=> Rails 5.1.7 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
Puma version: 5.5.2 (ruby 2.6.3-p62) ("Zawgyi")
Min threads: 5
Max threads: 5
Environment: development
PID: 12446
Listening on http://127.0.0.1:3000
Listening on http://[::1]:3000
Use Ctrl-C to stop
Started GET "/" for ::1 at 2021-11-10 12:28:58 +0530
Started GET "/recommendations" for ::1 at 2021-11-10 12:29:20 +0530
Started GET "/" for ::1 at 2021-11-10 12:29:39 +0530
Started GET "/" for ::1 at 2021-11-10 12:29:40 +0530
I tried many things like changing the port, making sure that the rails version in my local and gemfile are the same, trying with other ruby versions, uninstalling and reinstalling ruby and rails in local.
Tried keeping binding.pry in the application controller's index action but that not getting hit. I am not able to exit from that point, the server gets stuck there. There are no recent changes in my application.
Can anyone suggest to me what might be the problem?

Heroku Rails server API not setting the correct port number when starting up

I have a Rails API Backend with a React front end that is deployed to Heroku. When I try to load a page that makes a call to the API, it hangs and then finally gives this error in the console:
GET https://MYAPP.herokuapp.com:3001/auth/refresh_token net::ERR_TIMED_OUT
When I look at the logs while the application is starting up, it looks as though I'm setting the port to 3001 which is what I want but it looks as those puma is listening on a different port number:
2020-10-01T04:28:51.720203+00:00 heroku[web.1]: Starting process with command `bundle exec puma -t 5:5 -p ${PORT:-3001} -e ${RACK_ENV:-production}`
2020-10-01T04:28:55.321298+00:00 app[web.1]: Puma starting in single mode...
2020-10-01T04:28:55.321325+00:00 app[web.1]: * Version 4.3.5 (ruby 2.6.6-p146), codename: Mysterious Traveller
2020-10-01T04:28:55.321326+00:00 app[web.1]: * Min threads: 5, max threads: 5
2020-10-01T04:28:55.321326+00:00 app[web.1]: * Environment: production
2020-10-01T04:29:04.625683+00:00 app[web.1]: * Listening on tcp://0.0.0.0:55912
Should I be configuring my fetches to use this URL instead?: https://MYAPP.herokuapp.com/auth/refresh_token
Basically, what I'm asking is: Based on this log information where is my Rails API listening if my React application is listening at: https://MYAPP.herokuapp.com?

Rails Server working in command line. Not at Localhost

rails server
=> Booting Puma
=> Rails 5.2.0 application starting in development
=> Run rails server -h for more startup options
[44266] Puma starting in cluster mode...
[44266] * Version 3.6.2 (ruby 2.5.1-p57), codename: Sleepy Sunday Serenity
[44266] * Min threads: 5, max threads: 5
[44266] * Environment: development
[44266] * Process workers: 1
[44266] * Preloading application
[44266] * Listening on tcp://localhost:3000
[44266] Use Ctrl-C to stop
[44266] - Worker 0 (pid: 44286) booted, phase: 0
^C[44266] - Gracefully shutting down workers...
[44266] === puma shutdown: 2018-06-12 14:28:53 -0500 ===
[44266] - Goodbye!
Exiting
went to http://www.localhost3000.org/
says you forgot to start your server
Running
Rails 5.2.0
Postgesql 9.6
It looks like http://www.localhost3000.org/ is a website that someone bought to help you when you mistype your attempt to get to your localhost. It's not your own server responding
As the website suggests, try to go instead to http://localhost:3000
Use this address localhost:3000. The link you included is a live website someone has published as a reminder to start your server.
Use this address http://localhost:3000 but you can still edit your url, follow this article: Edit localhost

Rails initializer (using JRuby, Puma) at_exit is occasionally not executed

I'm trying to make a little library that wraps over march_hare and is used as part of our Rails app. It needs to connect on app startup and disconnect on shutdown.
I'am aiming to something similar to the ruby-kafka Rails integration via initializer:
configure my service
run it
specify shutdown procedure
The problem is my at_exit blocks are sometimes not executed. What may be the cause of this issue? Is there a way to fix it and ensure my at_exit blocks are called?
Investigating the issue, I created a blank demo app with the following initializer:
class SomeClass
def self.shutdown(reason)
msg = "#{Time.now} SHUTDOWN via #{reason}!"
puts msg
open('log/development.log', 'a') do |f|
f.puts msg
end
end
end
at_exit { SomeClass.shutdown(:at_exit1) }
at_exit { SomeClass.shutdown(:at_exit2) }
at_exit { SomeClass.shutdown(:at_exit3) }
puts "#{Time.now} INITIALIZED!"
In 9 out of 10 run + terminate cycles I get:
$ rails s
=> Booting Puma
=> Rails 4.2.7.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
2017-05-22 15:29:16 +0300 INITIALIZED!
Puma starting in single mode...
* Version 3.4.0 (jruby 9.1.2.0 - ruby 2.3.0), codename: Owl Bowl Brawl
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
^C- Gracefully stopping, waiting for requests to finish
Exiting
=== puma shutdown: 2017-05-22 15:29:30 +0300 ===
- Goodbye!
2017-05-22 15:29:30 +0300 SHUTDOWN via at_exit3!
2017-05-22 15:29:30 +0300 SHUTDOWN via at_exit2!
2017-05-22 15:29:30 +0300 SHUTDOWN via at_exit1!
But once in a while the result is:
$ rails s
=> Booting Puma
=> Rails 4.2.7.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
2017-05-22 15:29:45 +0300 INITIALIZED!
Puma starting in single mode...
* Version 3.4.0 (jruby 9.1.2.0 - ruby 2.3.0), codename: Owl Bowl Brawl
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
^C- Gracefully stopping, waiting for requests to finish
Exiting
=== puma shutdown: 2017-05-22 15:30:17 +0300 ===
- Goodbye!
2017-05-22 15:30:17 +0300 SHUTDOWN via at_exit2!
2017-05-22 15:30:17 +0300 SHUTDOWN via at_exit1!
My Gemfile has only gem 'puma' added.
Ruby version: jruby 9.1.2.0
Rails version: Rails 4.2.7.1
System Version: macOS 10.12.4
This is something to do with JRuby. You could try upgrading JRuby to the latest version and see if that's fixed.
Else follow this thread for more reference.
https://github.com/jruby/jruby/issues/5437

Rails app on heroku stopped working

I have a rails app deployed on heroku. It worked for about a year. Lately I just can't enter the app. Connection takes too long. I tried to restart dynos but it has no effect. I have also changed from unicorn to puma.
After restart I have in logs
2016-01-20T21:15:06.007597+00:00 app[web.1]: Puma starting in single mode...
2016-01-20T21:15:06.007619+00:00 app[web.1]: * Version 2.15.3 (ruby 2.0.0-p648), codename: Autumn Arbor Airbrush
2016-01-20T21:15:06.007621+00:00 app[web.1]: * Min threads: 5, max threads: 5
2016-01-20T21:15:06.007622+00:00 app[web.1]: * Environment: production
2016-01-20T21:15:09.455202+00:00 heroku[web.1]: State changed from starting to up
2016-01-20T21:15:09.218059+00:00 app[web.1]: I, [2016-01-20T21:15:08.018346 #3] INFO -- : Loading Rails (4.2.5) integration
2016-01-20T21:15:09.218129+00:00 app[web.1]: appsignal: Starting AppSignal 0.11.7 on 2.0.0/x86_64-linux
2016-01-20T21:15:09.221967+00:00 app[web.1]: appsignal: Started Appsignal agent
2016-01-20T21:15:09.323110+00:00 app[web.1]: * Listening on tcp://0.0.0.0:48877
== EDIT: ==
After curl I get
curl: (52) Empty reply from server
I have found here stack overflow question to use https instead of http, however from https curl I get
curl https://myapp.herokuapp.com
<html><body>You are being redirected.</body></html>%
I have run out of ideas. Any help would be appreciated.
It turend out that server settings was the problem. I had a redirection to ip. Don't know how it had worked for so long. I have changed it for a CNAME record and it works like a charm.

Resources