So you're very new to Ruby? Good thing you found us!
We're going to take you on an ADVENTURE!
This project was started to provide puzzles for people pondering programming. We found that Ruby was pretty welcoming and provides some great tools to get started in web development. It's also a beautiful language :-)
We are using a tool called Sinatra for this exercise. It is, for our intents, a stripped down version of Ruby on Rails.
This guide is written against using Cloud9 as it reduces barriers a lot lower than a local install. We've followed Ruby on Rails Tutorial (3rd Ed.) on this one.
- Set up a Cloud9 Account: Cloud9 - Your development environment, in the cloud
- On your dashboard
CREATE A NEW WORKSPACE
- Fill in
Workspace name
withruby-newbie
- Fill in
Clone from Git or Mercurial URL
withhttps://github.com/ZachBeta/ruby-newbie
- Click the
Custom
project - Click
Create
- Click on the
ruby-newbie
project that shows up in the left sidebar.
You should now see directory structure on the left with various projects such
as hello_world
and bootstrap
. You can explore the projects by clicking on
the various files and directories.
For more information see the individual project sections below.
If you do not want to use Cloud9 and are comfortable installing code on your own laptop. Follow the steps in this section to get a Ruby development environment running on your own machine. This is a strong alternative to using the Cloud9 service described in the previous section, but will take a lot more setup time.
- Install Ruby on Rails based on this guide: Install Rails | Your Guide for Installing Ruby on Rails
- We will not be using Rails right now, but the setup is VERY similar.
- If you're new to GitHub we recommend using one of the links on the right hand side of this page:
Download ZIP
or download the zip here - Unzip into your favorite directory. We recommend a "workspace" directory in your home directory:
~/workspace
- Open it in your editor of choice. If you don't have a preferred editor, we like to recommend Sublime Text to beginners.
- Let's take for example
hello_world
... - Before anything else you'll need to get the right libraries installed for ruby. You can do this by running
bundle
in your terminal - Open up the directory and file in your editor:
hello_world/hello_world.rb
. - Notice that
hello_world.rb
will have instructions in the comment block to explain how to run it. We're going to walk through that here too. - From your terminal run:
cd hello_world
to get your terminal into the correct directory. - If you're using Cloud9, you can run the app with
ruby hello_world.rb -p $PORT -o $IP
. If you're not using Cloud9, you can skip the extra parameters and run withruby hello_world.rb
- Now you can open up the website. If you're using Cloud9 there will be a link shown that you can click. If you're not using Cloud9, you can find the app at
http://localhost:4567
- When you want to terminate the application, go to your terminal and press
ctrl
andc
. In the context of a terminal this is not "copy" like you may be used to. - You can then navigate your terminal back to the main directory with:
cd ..
will go up one directory, orcd ~/workspace
which will go to your personal workspace directory. - Now you can follow the same pattern for each of the other micro apps.
- Each app will also have some challenges to give you an idea of how you can change or improve the app and improve your familiarity with it.
Simple web apps to explore web development with Ruby:
- Hello World
hello_world
Hello World website in Sinatra- Get a basic sinatra webapp running
- HTML template tools
template
Serve erb templates- Use erb templates with sinatra
- CSS
bootstrap
Serve erb templates with twitter bootstrap- Use erb templates with css and js assets
- Forms
form
- Handle simple form behavior with sinatra
- Using libraries
sentence_diff
- Use a library to calculate a diff between two strings of text
- Hosting
hello_heroku
- Deploy a simple sinatra app to a real web server
- CSVs
csv_uploader
- Upload a CSV and display the data in a table
- Dates and Times
friday
"Is it friday yet?" website clone- Use some Ruby date functions in a sinatra site
- Working with ruby hashes
dictionary
- allow a user to input words and definitions into a memory backed dictionary
- API Calls and image tags
gallery
- show a set of gifs found on giphy
pokemon
- show data about pokemon using PokeAPI
- URL shortener
url_shortener
- Make some custom URL shorteners
- Fork the project, make some commits, and open a pull request! :-)
- Take some of the boilerplate samples (
template
orhello_world
, etc.) and make some new projects we can add to our portfolio - Take a look at our
TODO.md
file where we've collected a ton of raw ideas for improvements. - File an issue and give us some feedback on the apps, especially if you run into any trouble with them.
- There's some very common issues people run into that we'll be updating in this README as they arise.