2016年1月19日 星期二
2015年7月5日 星期日
[Ruby] Ruby online Resource
- Editor(RecommandSublime Text)
- Ruby on Rails 環境
- Mac user online - tutor:Mac OS X 上配置 Ruby on Rails 開發環境
- Linux user online - tutor:Linux 上配置 Ruby on Rails 開發環境
- Windows user install VirtulBox, and Download virtual image mount into VirtualBox.
- irb = interactive Ruby
- Standard library - stdlib
- Extend library - gem
By using require to include library Ex: require 'open-uri'
Reference:
Game
Online Tutor
2014年5月10日 星期六
[Ruby on Rails] Create a first program "Hello World " at the views folder
1. Go to app/controllers
2. Edit gedit blog_controller.rb
class BlogController < ApplicationController
def index
end
end
Edit gedit app/views/blog/index.rhtml
hello world my first Ruby on Rails
3. Open Browser type : http://0.0.0.0:3000/blog
Reference:
[Ruby on Rails] Create a first program "Hello World " at the controller folder
1. Create a control was called blog
script/generate controller blog
2. Go to app/controllers
3. Edit gedit blog_controller.rb
class BlogController < ApplicationController
def index
render :text => "Hello World!!"
end
end
4. Open Browser type : http://0.0.0.0:3000/blog
Reference:
[Sqlite3][Ruby on Rails] How to install sqlite3 by using gem install
[Sqlite3][Ruby on Rails] How to install sqlite3 by using gem install
Question :
sudo gem install sqlite3-ruby
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
extconf.rb:3:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:3
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/sqlite3-1.3.9 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/sqlite3-1.3.9/ext/sqlite3/gem_make.out
Solution :
sudo apt-get install ruby-dev
Reference:
[Ruby on rails] Start script/server error
[Ruby on rails] Start script/server error
Question :
When I want to start the server.
I type script/server
The error like the following
no such file to load -- net/https (RuntimeError)
Solution :
sudo atp-get install libopenssl-ruby1.8
Reference:
2014年5月2日 星期五
2014年5月1日 星期四
[ruby] Install rails
[ruby] Install rails
Prepare :
sudo apt-get install zlib1g-dev
After tar xvf ruby-2.1.1.tar.gz
cd ruby-2.1.1/ruby-source-files/ext/zlib
ruby extconf.rb
sudo make install
Will install zlib
Start :
1. gem install rails --include-dependencies
2. Test rails install successfully
happy@ubuntu:~/Downloads/rubygems-1.8.25$ rails -v
Rails 4.1.0
Reference:
Install RubyGems
[ruby] Install RubyGems
1. Go to http://rubyforge.org/
2. Search RubyGems
3. Download rubygems-1.8.25.tgz from webpage
4. tar xvf rubygems-1.8.25.tgz
5. cd rubygems-1.8.25
ruby setup.rb
6. Display successful message like following
happy@ubuntu:~/Downloads/rubygems-1.8.25$ ruby setup.rb
RubyGems 1.8.25 installed
== 1.8.25/ 2013-01-24
* 6 bug fixes:
* Added 11627 to setup bin_file location to protect against errors. Fixes #328 by ConradIrwin
* Specification#ruby_code didn't handle Requirement with multiple
* Fix error on creating a Version object with a frozen string.
* Fix incremental index updates
* Fix missing load_yaml in YAML-related requirement.rb code.
* Manually backport encoding-aware YAML gemspec
------------------------------------------------------------------------------
RubyGems installed the following executables:
/home/happy/bin/gem
7. Test gem version, and make sure install gem successfully
happy@ubuntu:~/Downloads/rubygems-1.8.25$ gem -v
1.8.25
[ruby] How to install ruby in Ubuntu 10.04
Method 1 :
sudo apt-get install ruby
Method 2 :
1. Install essential package for development
sudo apt-get install build-essential zlib1g-dev
2. Download new and stable of ruby package from https://www.ruby-lang.org/
3. tar xvf ruby-2.1.1.tar.gz
4. Configuration and make install
cd ruby-2.1.1
Method A :
./configure
make
make install
Method B :
./configure -prefix=$HOME
make
make install
vim ./.bashrc
Add following command
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH