Solve Error in Windows Command: TZInfo::DataSourceNotFound

How to Resolve TZInfo::DataSourceNotFound Error

If you are using Windows to make Ruby on Rails apps and come across this error in your command prompt when trying to run the Rails server:

C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/tzinfo-1.2.2/lib/tzinfo/data_source.rb:182:in `rescue in create_default_data_source': No source of timezone data could be found. (TZInfo::DataSourceNotFound)
Please refer to http://tzinfo.github.io/datasourcenotfound for help resolving this error.

Add this to the Gemfile in your app:

gem 'tzinfo-data', platforms: [:mingw, :mswin]

Run $bundle install
And then run your Rails server again. $rails server

How to create links in Rails

Creating links can be confusing if you are just starting to learn Rails. It is important to understand how your views, controllers, and routes are connected.

If you already have an app you are working on, simply type:

$rake routes

This command will let you see all your routes, how your views connect to your controller, their URLs, and how to link them in your HTML.erb file.

For example, this is mine:
rake routes rails

The ‘Prefix’ column contains the name of the link path that you will use.

The ‘Verb’ column tells you what HTTP actions are connected to each path:

 REST verb GET POST PUT DELETE
Action show create update destroy

The ‘URI Pattern’ column is the URL link

The ‘Controller#Action’ column gives you the name of the controller and the name of the method action connected with the page.

Taking the above information, we can open our ‘views/articles/index.html.erb’ page and start adding links!

Before you start, it is important to understand the difference between <% and <%=. The difference is:

  • <%..%> is for items you DO NOT want to appear in the view (like if statements and iterations).
  • <%=..%> is for items you DO want to appear in the view (like images and links).

To create a link in your html.erb file, you can follow this example:

<%= link_to "Text to show", model_instance %>

It will generate html that looks like this:

<a href="http://www.url.com/model_instance">Text to show</a>

Let’s create our own using the routes listed in our $rake routes using the above example.

<% link_to "New Article", new_article_path %>

The HTML for the link will look like so:

<a href="/articles/new">New Article</a>

To add a class to the link, just include it at the end:

<% link_to "New Article", new_article_path, class: "btn btn-default" %>

To add an image, use the following code recipe:

<%= image_tag('image.jpg') %>

4 Affordable Coding Boot Camps

I am finding it increasingly more challenging trying to improve and learn as a coder. There’s no one to ask questions to or collaborate with, also to help me think in a different way. I’ve reached a point where I realize the limits of self-teaching and how important a collaborative environment is. I’ve been researching affordable boot camps and have found four that seem reasonable.

  1. Recurse Center is a three-month retreat where programmers can go to immerse themselves in a programming environment and work on real-world projects with other attendants. During the three months, you will be studying on your own in a project-based environment, but surrounded by mentors and similar peers. It’s not a boot camp, nor is it for beginners. After the three months, it is possible to get employment from one of the many companies that work with Recurse Center.Recurse Center is located in New York, and with the high cost of living, they offer grants for those who cannot afford to pay housing during the three-month-period. This is definitely something I am able to and want to do.
  2. LAMP Camp is located in Atlanta, Georgia and is similar to Recurse Center in that it let’s you work on real-world projects while you grow as a programmer. Their boot camp program goes for 12-weeks and is sponsored by CRESCA Group, where most of the projects you will be working on come from. What’s great about LAMP Camp is that they teach you how to work on a development team using Agile project management principles. So not just the programming side of things, but also the business side. Instead of focusing on Ruby on Rails, or Javascript, Lamp Camp focuses on PHP and MySQL databases.
  3. Dev Mountain has two locations, one in Provo, Utah, and one in Dallas, Texas. In addition to web development, they offer iOS development and UX Design. Their tuition for the immersive 13-week web development program is pricey, but cheaper than most boot camps at $8,900-9,500. What’s great about their price is it includes a gym membership, HOUSING, and a public transit pass for your time there. With all that included, it’s not bad. Their program focuses on Javascript, with AngularJS, Node.js, React, MongoDB, and more.
  4. App Academy is located in San Francisco and New York City and offers a 12-week immersive full-stack developer boot camp. What’s great about App Academy is you don’t pay any tuition. If you are able to find a job after graduating, they take a one-time placement fee that’s 18% of your salary.  An impressive 98% of their graduates are able to find jobs after graduation. During their program, you will be learning HTML, CSS, Ruby, Rails, jQuery, PostgreSQL, Backbone.js, and Javascript. I’ve applied for their program and let me warn you, it is VERY competitive and also you have to complete a series of programming exercises (20 of them) to even get a phone interview. Not to mention you will also have to do some programming exercises during the in-person interview. They only accept 5% of their applicants and to keep their applicants from dropping out of the free boot camp, they require a deposit of $5,000.

Github Pages

Did you know that you can use Github Pages to host your websites live?

It’s free and easy to setup whether you are on Windows or Mac.

There are two different types of Github Pages, one for Users & Organizations, and one for Projects. Each User & Organization can only have ONE Github Page. With each Github Page, you can have unlimited Project Pages. Project Pages are located as a subpath to the User Page (http://username.github.io/projectpage). To get more information about the similarities and differences, click here.

To set up a User Page, you first will need to create a new repository called username.github.io (where username is your Github username). This will be the URL of your website.

Then follow the instructions located here: https://pages.github.com/

To read about setting up a custom domain, go here.
Adding a CNAME file to your repository (for custom domains), go here.

Added Stripe gem to Rails app

Part VII of Codermanual is broken into three different sections. I’ve just completed the first two and am extremely excited about how my Rails app is coming along! We integrated Stripe, Devise, and Figaro gems into our app to add secure, authentic credit card payment to our membership site.

  • To use Stripe, you will need to sign up for a free account on their website: https://stripe.com/ 
  • Devise is an authentication gem. Read more about how to integrate it into your Rails app here.
  • Figaro helps you securely configure your Rails application.

Web application views

The home page:
heroku codermanual app

Alert for user sign-out:
Unnamed QQ Screenshot20150819055708

The sign-up screen for the Pro account:
pro account rails application

The sign-up screen for the Basic account:
basic account rails app

Icons | Gradients | Asset Pipeline

I’ve just completed the first part of Part VII of Rob Dey’s Codermanual course! He recommended some great resources for styling your website and improving site loading speed.

This is what my Rails app looks like so far, after completing the first part of Part VII:
codermanual saas


Font Awesome

If you want to add icons to your website, you can go to Font Awesome where there are tons of free pre-made icons. You can resize the icons, add them to a drop-down menu, and also add animations to the icons.

You can read their Getting Started page here to learn how to integrate it into your Rails app.


UIGradients

UI Gradients Color Design
A great website for getting CSS codes for pre-made color gradients. The website has a beautiful layout, with easy navigation. Click on the gradient you fancy and check out the CSS code. Simply copy and paste into your project!


Asset Pipeline

The asset pipeline in Ruby on Rails combines all your CSS files into one file, and all your JavaScript files into one file. Compressing them for faster loading speeds. In Rails 4, the asset pipeline is automatically added in your Gemfile under:

gem 'sass-rails'
gem 'uglifier'
gem 'coffee-rails'

If you don’t want your Rails application to automatically load the asset pipeline feature, you can just type this when creating a new Rails app:

$ rails new appname --skip-sprockets

Read more here: http://guides.rubyonrails.org/asset_pipeline.html


PageSpeed Insights

Enter your website URL here to check how fast your site loads on both mobile and desktop. Google will recommend what improvements you should make as well as let you know what you are doing right.
pageinsights google

Solution to Application Error on Heroku

I’ve just completed Chapter 8 of the Hartl Rails Tutorial and wanted to deploy my application onto Heroku.

After running the below code in the Cloud 9 IDE terminal, I kept getting an Application Error page on my Heroku view.

$ bundle exec rake test
$ git push
$ git push heroku
$ heroku run rake db:migrate

Application Error page on Heroku:

Application Error Heroku

After perusing the internet for a solution, I found a YouTube video that explains how to find the errors that could lead to an Application Error. You can view the video here.

On the Application Error page, it says:

If you are the application owner, check your logs for details.

To check your logs, enter this into your terminal:

$ heroku logs --tail

This will be similar to what your logs will look like:

2015-08-11 .. +00:00 heroku[run.8473]: State changed from starting to up
2015-08-11 .. +00:00 heroku[run.8473]: State changed from up to complete
2015-08-11 .. +00:00 heroku[run.8473]: Process exited with status 0
2015-08-11 .. +00:00 heroku[api]: Set maintenance mode off by yourname@email.com
2015-08-11 .. +00:00 heroku[web.1]: Unidling
2015-08-11 .. +00:00 heroku[web.1]: State changed from down to starting
2015-08-11 .. +00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rbbu`
2015-08-11 .. +00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/configuration.rb:179:in `read': No such file or directory - config/puma.rbbu (Errno::ENOENT)
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/configuration.rb:179:in `_load_from'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/configuration.rb:40:in `load'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/cli.rb:308:in `parse_options'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/bin/puma:10:in `<top (required)>'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/cli.rb:453:in `run'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/puma:23:in `load'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/puma:23:in `<main>'
2015-08-11 .. +00:00 heroku[web.1]: State changed from starting to crashed
2015-08-11 .. +00:00 heroku[web.1]: State changed from crashed to starting
2015-08-11 .. +00:00 heroku[web.1]: Process exited with status 1
2015-08-11 .. +00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rbbu`
2015-08-11 .. +00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/configuration.rb:179:in `read': No such file or directory - config/puma.rbbu (Errno::ENOENT)
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/configuration.rb:179:in `_load_from'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/configuration.rb:40:in `load'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/cli.rb:308:in `parse_options'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/cli.rb:453:in `run'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/bin/puma:10:in `<top (required)>'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/puma:23:in `load'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/puma:23:in `<main>'
2015-08-11 .. +00:00 heroku[web.1]: State changed from starting to crashed
2015-08-11 .. +00:00 heroku[web.1]: Process exited with status 1
2015-08-11 .. +00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=salty-cove-3725.herokuapp.com request_id=fdda059e-0ce2-486a-b855-fedcb612368d 
2015-08-11 .. +00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=salty-cove-3725.herokuapp.com request_id=5e08ce0d-b815-4278-be4c-5e5ce636352d
2015-08-11 .. +00:00 heroku[web.1]: State changed from crashed to starting
2015-08-11 .. +00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rbbu`
2015-08-11 .. +00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/configuration.rb:179:in `read': No such file or directory - config/puma.rbbu (Errno::ENOENT)
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/configuration.rb:179:in `_load_from'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/configuration.rb:40:in `load'
2015-08-11 .. 00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/cli.rb:453:in `run'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/cli.rb:308:in `parse_options'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/bin/puma:10:in `<top (required)>'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/puma:23:in `load'
2015-08-11 .. +00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/puma:23:in `<main>'
2015-08-11 .. +00:00 heroku[web.1]: Process exited with status 1
2015-08-11 .. +00:00 heroku[web.1]: State changed from starting to crashed
2015-08-11 .. +00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=salty-cove-3725.herokuapp.com request_id=188280eb-4424-4a09-8a77-5d8831450666
2015-08-11 .. +00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=salty-cove-3725.herokuapp.com request_id=4a0567fe-7819-40da-9aa2-cec5b341d48e
2015-08-11 .. +00:00 heroku[api]: Starting process with command `rails console` by heeycutie@yahoo.com
2015-08-11 .. +00:00 heroku[run.3262]: Awaiting client
2015-08-11 .. +00:00 heroku[run.3262]: Starting process with command `rails console`
2015-08-11 .. +00:00 heroku[run.3262]: State changed from starting to up
2015-08-11 .. +00:00 heroku[run.3262]: State changed from up to complete
2015-08-11 .. +00:00 heroku[run.3262]: Process exited with status 0

Looking through the logs, I found this first problem:

2015-08-11 .. +00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/configuration.rb:179:in `read': No such file or directory - config/puma.rbbu (Errno::ENOENT)

It was trying to find a file named puma.rbbu in my /config folder, and the file wasn’t there. To address this, I set out to find the file.

Opening up my /config folder in Cloud 9, I saw that my puma file was named puma.rb, not puma.rbbu. I renamed the puma.rb file extension to puma.rbbu and then pushed the repository up to Heroku again.

This time it worked! My app is online and running here: https://salty-cove-3725.herokuapp.com/


Just a note:

I had my application on Bitbucket in a private repository. I had originally thought this was the reason why I was getting the Application Error page. I moved my Bitbucket repo over to Github into a public repo to test out if this was the case. The Application Error page still showed up. So it doesn’t matter whether your app is public or private. As long as you pushed your project onto Heroku successfully, something else is causing the error.

Ruby on Rails Resources

Ruby:

https://www.ruby-lang.org/en/news/2013/12/25/ruby-2-1-0-is-released/

Rails:

http://guides.rubyonrails.org/4_0_release_notes.html

Rails Installation Guide:

http://railsinstaller.org/en
http://guides.railsgirls.com/install/
http://installfest.railsbridge.org/installfest/ I used this one to install on my Windows OS because I attended a RailsBridge event. I found it easy to follow. 

Ruby Gems:

https://rubygems.org/

Bundler:

http://bundler.io/
Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed.

Learn Ruby:

TryRubyhttp://tryruby.org/levels/1/challenges/0 Really fun way to get introduced to the language. Great layout&design and user friendly.
Ruby on Codecademy: https://www.codecademy.com/tracks/ruby Very well written and easy to follow.
Ruby Programming on Odin: http://www.theodinproject.com/ruby-programming
Ruby Monk: http://rubymonk.com/learning/books/1-ruby-primer
Ruby the hard way: http://learnrubythehardway.org/book/ It really is hard. Especially if you don’t have a programming background.
Ruby in 100 minutes: http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html
Chris Pinehttps://pine.fm/LearnToProgram/chap_01.html
Master Ruby blockshttp://mixandgo.com/blog/mastering-ruby-blocks-in-less-than-5-minutes
Bastards book of Rubyhttp://ruby.bastardsbook.com/toc/
Ruby Newbie Odin Gisthttps://gist.github.com/brianllamar/11261930

Learn Rails:

Rails for Zombies: http://railsforzombies.org/ Really excellent lessons. Read more here.
Tech Talent South Rails Beginner Lesson:
http://techtalentsouth.slides.com/techtalentsouth/zero-to-heroku-workshop?token=r_LQ9_iu#/
Michael Hartl’s Tutorial: https://www.railstutorial.org/book/beginning
Ruby on Rails on Odin: http://www.theodinproject.com/ruby-on-rails

Ruby Help

http://ruby-doc.org/
https://www.codecademy.com/glossary/ruby/

Blogs:

http://www.jamesfend.com/learned-ruby-rails-12-weeks-launch-freelancify
http://www.codenewbie.org/blogs/ruby-roundup-1
http://www.smashingmagazine.com/2009/03/getting-started-with-ruby-on-rails/

Atlanta Ruby Users Group:

http://www.atlrug.com/

Jobs:

https://toprubyjobs.com/
https://www.jrdevjobs.com/jobs

Ruby Regular Expression Editor:

http://www.rubular.com/

Rails for Zombies | Code School

I just completed the Rails for Zombies by Codeschool. It’s a FANTASTIC way to learn how Rails 4 works. The professor Gregg Pollack is great at explaining the code and how models are connected to controllers to views. The course Rails for Zombies Redux is free, includes 5 lessons, and follows the following structure: video lesson, 4-5 exercises to practice what you learn, wrap-up video.

There’s exercises after every video lesson that let you practice what Gregg explains in the video so you can apply what you learned. I highly recommend watching the video lessons more than once and have a pen and paper in hand (or whatever you use to take notes) to write down his clear explanations.

Here are some screenshots:

ruby for zombies

rails for zombies

rails for zombies codeschool

After completing the course, you can add a completion badge to your LinkedIn profile. I highly recommend this course to anyone learning Rails, and especially for before tackling the Hartl tutorial.