Ruby on Rails Resources

Monroe Mann

Published On: Oct 23, 2024

Editor’s Note: On all blog posts, we try to edit the writing as little as possible to preserve authenticity, personality, and writing style. We typically fix spelling errors, but minimally modify grammar and sentence structure (just enough to ensure readability).

Monroe Mann

Name: Monroe Mann Break Diving Level: Level 1 Number of Certified Dives: 14 From: United States In: United States

Monroe Mann is a web developer and founder of breakdiving.io

What follows is a list of Ruby on Rails resources, which I will update from time to time as I find worthy additions.  I hope these are helpful to you on your Ruby on Rails journey!  (Note: Originally published in 2017.  Has not yet been updated for 2024)

The many ways to use LINK_TO with rails
https://mixandgo.com/blog/how-to-use-link_to-in-rails

An easier way to RAKE ROUTES
Just type this into the browser while the server is running and the entire rake routes command will output in a MUCH cleaner format right in your browser: http://localhost:3030/rails/info/routes

Setting up SENDGRID with Heroku
https://thingsimfixing.wordpress.com/2016/11/20/rails-sending-automated-emails-with-devise-and-sendgrid-on-heroku/  As you will realize once you launch your app to Heroku (or any online host), if someone tries to reset their password, they will not receive the reset password email.  Why?  You probably forgot to set up SendGrid properly.  Here are the instructions (very clear) for how to do so.  This helped me out a lot when launching my first app, www.mymusic.bio.  Here is the link:

How to SETUP RAILS on Your Computer
https://gorails.com/setup/windows/10   This link is also good for Mac and Ubunto.  I haven’t yet gone through the steps, because I am currently using a Vagrant virtual box, but sometime soon, I plan to do a direct install on my computer, because lately, Vagrant has been working very slowly for me.  These directions, however, seem very straightforward.

LEARN RUBY ON RAILS for Free
https://www.theodinproject.com/   If you are familiar with www.FreeCodeCamp.com (which is also free), it’s the same thing, but instead of teaching you javascript and node.js, it teaches you ruby and rails.  This is definitely something I look forward to getting involved with soon, to further develop my Ruby on Rails skills.


Here is the Ruby Function to Ensure Word-Wrapping That Works Right!
https://stackoverflow.com/questions/2312153/wrapping-text-into-lines-at-word-boundaries#new-answer   The function is: word_wrap, and it looks like this in my todo list app called StriveList: <%= (word_wrap task.title, :line_width => 52).gsub(“\n”, “\n “) %>  All you have to do is put the function word_wrap in front, and then use some global substitutions on the backend.  Worked like a charm, and I’m grateful to jerodsanto on Stack Overflow for helping me out!

Quick reminder on how to do a simple if statement in .erb
<% if current_user %>
<%= f.text_field :title, placeholder: “You are logged in” %>
<% else %>
<%= f.text_field :title, placeholder: “You are using DEMO” %>
<% end %>

If you want to destroy all records in a database of a demo, i.e. where no one is logged in. and you have a user model:
Project.where(user: nil).destroy_all
NOTE: “Project” is whatever your model is called; user is what your users are called

Things uploaded to Heroku not working.
If things you upload to heroku aren’t taking effect, add this code to production.rb:
config.serve_static_assets = true
config.assets.compile = true
You can also try running precompiling the assets locally using:
RAILS_ENV=production rake assets:precompile
Finally, it may also be that you are saving precompiled assets locally, which is not recomnend.  You may have to delete the public/assets folder.

Random Commands You May Need To Use:
rails -c  OR rails console
quit (to leave rails console), or sometimes, ctrl c
git status
git add-all
git commit -am “message here”
git push origin master
rake routes
rake db:migrate
rake db:rollback
bundle exec rake assets:precompile (run this locally if css or other changes not taking on heroku)
heroku run rake assets:precompile
heroku run rake db:migrate
git push heroku master
heroku restart
ctrl c (to stop the local server)
rails s -b 0.0.0.0 (to start the server)
vagrant up (if using a vagrant virtual box)
vagrant halt

Add a Favicon to your app
It’s simple:
1. Download a .ico file to your assets/images folder or create your own FOR FREE at https://favicon.io/
2. Post this in application.html.erb in the header area:
<%= favicon_link_tag ‘favicon.ico’ %> (or whatever you named your favicon)

Break Diving, Inc. is a tax-exempt 501(c)(3) charitable organization.
Read all about our amazing mission at www.BreakDiving.org
Join our free community at www.breakdiving.io
Like what we do? Please make a feel-good donation!
Remember to tell your friends about this www.BreakDiving.blog



Read More Blog Posts on the Break Diving Blog Homepage