layout | title | permalink |
---|---|---|
default |
Setup recipe for Rails Girls |
install |
Cooking time: 5min active / 15-30min passive
To build apps and other things with Ruby on Rails, we need to setup some software and the developer environment for your computer.
Follow the instructions for your operating system. If you run into any problems, don’t panic. Inform us at the event and we can solve it together.
- Setup for OS X
- Setup for Windows
- Setup for Linux
- Alternative Installment for all OS
- Using a Cloud Service - No Installation Required
Click the Apple menu and choose About this Mac.
If your version number starts with 10.6, 10.7, 10.8, 10.9, 10.10 or 10.11 this guide is for you. If it’s something else, we can setup your machine at the event.
If your version number starts with 10.9, 10.10 or 10.11, follow these steps. We are installing homebrew and rbenv.
{% highlight sh %} xcode-select --install {% endhighlight %}
3a2. Install Homebrew:
{% highlight sh %} ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" {% endhighlight %}
3a3. Install rbenv:
{% highlight sh %} brew update brew install rbenv ruby-build echo 'eval "$(rbenv init -)"' >> ~/.bash_profile echo 'export PATH="$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile source ~/.bash_profile {% endhighlight %}
You can find the newest version of Ruby with the command "rbenv install -l".
{% highlight sh %} rbenv install 2.3.1 {% endhighlight %}
If you got "OpenSSL::SSL::SSLError: ... : certificate verify failed" error, try it this way.
{% highlight sh %}
brew install curl-ca-bundle
cp /usr/local/opt/curl-ca-bundle/share/ca-bundle.crt ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE'
{% endhighlight %}
{% highlight sh %} rbenv global 2.3.1 {% endhighlight %}
{% highlight sh %} gem install rails --no-document {% endhighlight %}
Download the RailsInstaller for your version of OS X:
- RailsInstaller for 10.7 and 10.8 (325MB)
- RailsInstaller for 10.6 (224MB)
Double click the downloaded file and it will unpack it into the current directory. Double click the the newly unpacked 'RailsInstaller-1.0.4-osx-10.7.app' or 'RailsInstaller-1.0.4-osx-10.6.app' and follow the instructions. It will open a README file with 'Rails Installer OS X' at the top. Please ignore the instructions in this file.
If the Rails version wasn't the latest, you could update it using a following command on terminal.
{% highlight sh %} gem update rails --no-document {% endhighlight %}
Make sure that all works well by running the application generator command.
{% highlight sh %} rails new myapp {% endhighlight %}
For the workshop we recommend the text editor Atom.
If you are using Mac OS X 10.7 or older versions, you can use another editor Sublime Text 2.
Open whatbrowser.org and update your browser if you don't have the latest version.
Now you should have a working Ruby on Rails programming setup. Congrats!
Download RailsInstaller and run it. Click through the installer using the default options.
Open Command Prompt with Ruby and Rails
and run the following commands to solve a problem in RailsInstaller3.2.0.
Coach: There is a bug in RailsInstaller3.2.0 that results in a "No such file or directory" error when using the rails
command. This is caused by incorrect paths in rails.bat
and bundle.bat
(see github issue for details).
We can fix the problem by copying rake.bat
to rails.bat
and bundle.bat
.
{% highlight sh %} cd C:\RailsInstaller\Ruby2.2.0\bin copy rake.bat rails.bat copy rake.bat bundle.bat {% endhighlight %}
Open Command Prompt with Ruby and Rails
and run the following command:
{% highlight sh %} rails -v {% endhighlight %}
If the Rails version is less than 5, update it using a following command:
{% highlight sh %} gem update rails --no-document {% endhighlight %}
If you get this error when running rails new railsgirls
or gem update rails
:
{% highlight sh %} Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://rubygems.org/gems/i18n- 0.6.11.gem) {% endhighlight %}
This means you have an older version of Rubygems and will need to update it manually first verify your Rubygems version
{% highlight sh %} gem -v {% endhighlight %}
If it is lower than 2.2.3
you will need to manually update it:
First download the ruby-gems-update gem. Move the file to c:\\rubygems-update-2.6.7.gem
then run:
{% highlight sh %} gem install --local c:\rubygems-update-2.6.7.gem update_rubygems --no-document gem uninstall rubygems-update -x {% endhighlight %}
Check your version of rubygems
{% highlight sh %} gem -v {% endhighlight %}
Make sure it is equal or higher than 2.6.7
. Re-run the command that was failing previously.
If you are still running into problems you can always find the latest version of rubygems online at rubygems.org. If you click on GEM you will get the latest version.
The Gem::RemoteFetcher::FetchError: SSL_connect
can also occur during the bundle install
stage when creating a new rails app.
The error will make mention of bit.ly/ruby-ssl. What is relevant for Windows users at this point is this GitHub gist. The described manual way has proven to be successful to solve the bundle install
error.
Sometimes you get the following error when running rails server
:
'x64_mingw' is not a valid platform
If you experience this error after using the RailsInstaller you have to do a small edit to the file Gemfile
:
Look at the bottom of the file. You will probably see something like this as one of the last lines in the file:
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
. If you have this line with :x64_mingw
, then please delete the :x64_mingw
part. In the end it should just say:
'tzinfo-data', platforms: [:mingw, :mswin]
After you did that, please use your Command Prompt again and type bundle update
.
For the workshop we recommend the text editor Atom.
- Download Atom and install it
- Download an atom zip file for windows and decompress it.
- Copy the folder into your Program Files.
- Launch atom in the folder.
If you are using Windows Vista or older versions, you can use another editor Sublime Text 2.
If you use Internet Explorer, we recommend installing Firefox or Google Chrome.
Open whatbrowser.org and update your browser if you don't have the latest version.
This is not strictly necessary, but it avoids a problem with and ExecJS::RuntimeError
that might
occur later (see stackoverflow).
- Go to https://nodejs.org/ and install node LTS package
- Reopen your Rails Command Shell
Check your version of node
{% highlight sh %} node --version {% endhighlight %}
Make sure it is displaying version number.
Check that everything is working by running the application generator command.
{% highlight sh %} rails new myapp cd myapp rails server {% endhighlight %}
Go to http://localhost:3000
in your browser, and you should see the 'Yay! You're on Rails!' page.
Now you should have a working Ruby on Rails programming setup. Congrats!
Coach: We recommend to verify by using the scaffold command and inputting data with the generated page with coaches to ensure everything is working.
To install the Ruby on Rails development environment you just need to copy the line below for your Linux distribution (Ubuntu or Fedora), paste it in the Terminal and press Enter. Enjoy the text flying on the screen; it will take quite some time. Grabbing a refreshing drink before starting is encouraged.
{% highlight sh %} sudo apt-get install curl bash < <(curl -sL https://raw.github.com/railsgirls/installation-scripts/master/rails-install-ubuntu.sh) {% endhighlight %}
If you are going to use RVM installations with gnome-terminal, you'll probably need to change it's default options before you can see and use the right Ruby and Rails versions. Find out how: RVM documentation.
{% highlight sh %} bash < <(curl -sL https://raw.github.com/railsgirls/installation-scripts/master/rails-install-fedora.sh) {% endhighlight %}
Make sure that all works well by running the application generator command.
{% highlight sh %} rails new myapp {% endhighlight %}
For the workshop we recommend the text editor Sublime Text.
Open whatbrowser.org and update your browser if you don't have the latest version.
Now you should have a working Ruby on Rails programming setup. Congrats!
Instead of installing all tools on your machine, you can also set up a development environment in a Virtual Machine. Please find all the details [here]({% post_url 2014-03-24-alternative-dev-environment %}).
Instead of installing Ruby on Rails and an editor on your computer, you can use a webservice for development. All you need is a browser and an internet connection. This guide explains how to get started with codenvy.io. If you're using a different service, they may use a different wording, but the process is usually pretty similar.
If you use Internet Explorer, we recommend installing Firefox or Google Chrome.
Open whatbrowser.org and update your browser if you don't have the latest version.
Go to codenvy.io and signup for free.
The Ruby on Rails Workspace has all the software we need for the workshop already preinstalled. To create a workspace, log into codenvy.io and click on 'Dashboard'. If no workspace has been created yet, the 'New Workspace' view is displayed.
In the 'New Workspace' view, a few settings have to be made.
- 'New from blank, template, or sample project' should already be selected
- Select 'Create new workspace from stack'
- Select 'Ready to go Stacks'
- Select 'Rails' Stack
- Give the workspace a name of your choice. In the example this is 'railsgirls'.
- Now click on 'Create' to create the workspace (it takes a moment for the process to finish)
- Codeenvy creates a folder '/projects' during initialization, in which you can later put your code. It also creates a folder 'console-ruby-simple' that we do not need. You can see it in the Project Explorer. Ignore it or delete it by right-clicking on the folder.
- If you've just created your project, you can probably skip these steps - they're good to know if you login to Codenvy again later
- If you haven't used your workspace or projects in a while, they might have been shutdown due to inactivity. You will notice an empty circle displayed next to the workspace name.
- In this case simply click on the name of the workspace. It will then be restarted (which can take a while) and afterwards opened.
- If you have restarted a workspace, you need to run the
bundle
command again in the directory of your Rails project (you will learn more about the command in the app tutorial)
-
On the left hand side, you find a file browser where you can navigate your directories and file
-
In the middle, you find the editor where you can modify your files
-
At the bottom, you find the terminal where you can run commands
-
Everything you need is right here in you browser window - you do not need to start an editor or terminal anywhere else
-
If you are following a guide or tutorial, use the commands for Linux even if you are on a Windows computer - your operating system does not matter, since all commands are run on your project's machine in the cloud, which is running Linux
-
If a guide or tutorial asks you to run a rails command that contains
rails
orrake
, prependbundle exec
to this command, e. g.bundle exec rake db:migrate
. Exception: therails new
command is not prefixed. -
If a guide or tutorial asks you to start the rails server with
rails server
orrails s
, append-b 0.0.0.0
to this command so that you runrails server -b 0.0.0.0
-
If a guide or tutorial asks you to point your browser to something like
http://localhost:3000
, follow these instructions instead:-
Go to ‘Workspaces’ and click your running workspace
-
Scroll down to 'Servers', and copy the Address entry in the line starting with 'server-3000-tcp'
For example, if the tutorial wants you to visit
http://localhost:3000/posts
, you would open the URLhttp://node3.codenvy.io:33079/posts
instead.
-