by Dr. Monroe Mann, PhD, Esq, MBA
Founder & Exec. Dir., Break Diving, Inc.
and… Ruby on Rails Developer
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!
The many ways to use LINK_TO with 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
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:
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:precompileFinally, 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 commit -am “message here”
git push origin master
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
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)
Add a Favicon to your app
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)