By Motash
I established DigitalOcean Droplet with Rails+Nginx+Puma (Rails version: 5.2.1, Ruby version: 2.5.1 (x86_64-linux), Ubuntu 18.04) and as a result I see popular “Yay! You’re on Rails!”. So I added new controller and view, updated routes.rb, precompiled assets, updated view to see the simpliest “Welcome” which I wrote inside a view, restarted server (rails.service). But as a result I see “not-my” page with a title “Example” and content of this page is a plain standard text “Hello”. And I cannot execute seeing “my” pages (neither in development nor production environment). This occurs only for routes defined in routes.rb. When I set this new view as the root route then I see this plain “Hello” text on a page also when I get a homepage (my_IP_address). When I turn off the root route then it’s “Yay! You’re on Rails!”. There are no errors in server log and access log show is ok too (codes 200). What am I missing? What should I do to see “my” pages?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
To resolve this issue and see your own pages, you need to make sure you have completed the following steps correctly first:
Create a new controller: Ensure that you have created a new controller using the appropriate Rails generator command, such as rails generate controller MyController.
Define routes: Open the config/routes.rb file and add the appropriate route for your new controller’s action. For example, if you have a welcome action in your MyController, you can add get '/welcome', to: 'my#welcome' to map the route.
Create a corresponding view: In the app/views directory, create a new directory called my and inside that directory, create a file named welcome.html.erb (or with the appropriate extension for your view format). Add your desired content to this view file.
Restart the server: After making changes to the routes and views, restart the server to ensure the changes take effect. If you’re using systemd to manage the Rails service, you can restart it using sudo systemctl restart rails.service.
If you have followed these steps correctly and are still experiencing issues, there are a few additional troubleshooting steps you can take:
Check the server logs: Look for any errors or warnings in the server logs. You can typically find the logs in the log/ directory of your Rails application. The logs may provide clues about what’s happening and help you identify the issue.
Verify asset compilation: Make sure that you have successfully precompiled your assets using the rails assets:precompile command. This step is necessary if you’re running your application in the production environment.
Check your Nginx configuration: If you’re using Nginx as a reverse proxy in front of Puma, ensure that your Nginx configuration is correctly routing requests to your Rails application.
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.