Ruby on Rails

From XennisWiki
Jump to: navigation, search

Ruby on Rails, or simply Rails, is an open source web application framework written in Ruby. Rails is a full-stack framework that emphasizes the use of well-known software engineering patterns and paradigms, including convention over configuration (CoC), don't repeat yourself (DRY), the active record pattern, and model–view–controller (MVC). (Wikipedia)

Installation

Windows

Further information: rubyonrails.org Download, Ruby on Rails Installation unter Windows

1) Install Ruby
ruby -v
2) Install NodeJs
apt-get install nodejs
3) Install Rails
  • Install Rails by the command (may attach –include-dependencies)
gem install rails
4) Create a sample application
  • Create the application myFirstApp
rails new path/to/myFirstApp
cd path/to/myFirstApp
rails server

IDE

A list of IDE's you find on the offical website on the download page and then in the section Editors. See also Ruby

Errors and problems

json requires installed build tools

Error message
ERROR: Error installing rails:
       The 'json' native gem requires installed build tools.
Solution
  • Download the Development Kit
  • Extract it in the Ruby installation folder under C:\Ruby193\DevKit
cd C:\Ruby193\DevKit
ruby dk.rb init
ruby dk.rb review
ruby dk.rb install

file 'lib' not found

Error message
file 'lib' not found
Solution
gem install rails --no-ri --no-rdoc

Could not find a JavaScript runtime

Error message
Could not find a JavaScript runtime.
Solution

Install Node.js

TZInfo::DataSourceNotFound

Error message
Exiting
C:/Ruby21-x64/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 timezone data source could be found. (TZInfo::DataSourceNotFound)

Solution[1]

  • Open the Gemfile file in your application and find the following line:
gem 'tzinfo-data', platforms: [:mingw, :mswin]
  • Add a :x64_mingw to the list of platforms, if you are using Windows 64-bit version
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
  • Open the command line in your application and run bundle update

Account isn't allowed to install to [...] Rubygems

Error message
Fetching gem metadata from https://rubygems.org/.........


Your user account isn't allowed to install to the system Rubygems.
You can cancel this installation and run:

    bundle install --path vendor/bundle

to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to Rubygems using sudo.
Solution
apt-get install rbenv

See also

References

External links