覚えたことを復唱してみる。 だって、忘れっぽいんですもの。

Rails4 HelloWorld

http://guides.rubyonrails.org/getting_started.htmlを見ながらRails4でHelloWorldやってみました。

```$ rails new blog $ cd blog $ vi Gemfile(追記) gem ‘execjs’ gem ‘therubyracer’ $ rails server


```$ rails generate controller welcome index
$ vi app/views/welcom/index.html.erb
(全部消して、したのを書く)
<h1>Hello, Rails!</h1>

アプリケーションのホームページにする config/routes.rbを編集する

Blog::Application.routes.draw do
get “welcome/index”
# The priority is based upon order of creation:

# first created -> highest priority.
# …
# You can have the root of your site routed with “root”
# root to: “welcome#index”

これを

Blog::Application.routes.draw do
get “welcome/index”
# The priority is based upon order of creation:

# first created -> highest priority.
# …
# You can have the root of your site routed with “root”
root to: “welcome#index”  ⬅コメントはずした

これでhttp://localhost:3000/welcome/index これでも、

http://localhost:3000/これでもアクセスできます。

もう一回、AWSにRails4とか

AWS設定

ec2:Tokyo:t1.micro
AMI: amzn-ami-pv-2013.03.1.x86_64-ebs (ami-39b23d38)

Railsインストール 参照:http://tsuchikazu.net/linux_ruby_on_rails_install/

$ sudo yum install git

$ sudo yum -y install make 
$ sudo yum -y install gcc 
$ sudo yum -y install gcc-c++ 
$ sudo yum -y install zlib-devel 
$ sudo yum -y install openssl-devel 
$ sudo yum -y install httpd-devel 
$ sudo yum -y install curl 
$ sudo yum -y install curl-devel 
$ sudo yum -y install readline-devel 
$ git clone git://github.com/sstephenson/rbenv.git .rbenv

$ echo ‘export PATH=”$HOME/.rbenv/bin:$PATH”‘ >> ~/.bash_profile
$ echo ‘eval “$(rbenv init -)”‘ >> ~/.bash_profile
$ source .bash_profile 
$ rbenv (確認)
$ git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

$ rbenv install (確認)
$ rbenv install -l (確認)

$ rbenv install 2.0.0-p247
$ rbenv install 1.9.3-p448
$ rbenv versions (確認)
$ rbenv global 2.0.0-p247(切替) 
$ rbenv versions (確認)
$ ruby -v (確認)
$ gem search -r rails

$ gem install rails –no-ri –no-rdoc
$ source ~/.bash_profile
$ sudo yum install sqlite-devel

$ gem install sqlite3
$ gem install spring
$ gem install therubyracer
$ rails -v

$ rails new sample1
$ cd sample1
$ vi Gemfile
(追記)
gem ‘execjs’
gem ‘therubyracer’
$ rails server

AWSにrails4とか – rails4起動

rails new railstest –edge
cd railstest
bundle install
bundle exec rails server

下のメッセージが出たら成功

 INFO  WEBrick 1.3.1
 INFO  ruby 2.0.0 (2013-05-14) [x86_64-linux]
 INFO  WEBrick::HTTPServer#start: pid=3391 port=3000

http://localhost:3000

に接続

img

AWSにrails4とか – rails残り

rails4だったために下を全部入れないとnewできず。。 うーん。めんどくさい。

gem install activesupport –pre

gem install actionmailer –pre
gem install activemodel –pre
gem install activerecord-deprecated_finders -v ‘1.0.2’
gem install activerecord –pre
gem install bundler
gem install coffee-script-source
gem install coffee-script
gem install coffee-rails
gem install execjs
gem install jquery-rails
gem install sass
gem install sass-rails
gem install sqlite3
gem install uglifier
gem install libv8
gem install therubyracer
gem install rake
gem install jbuilder -v ‘1.0.2’
gem install therubyracer
gem install bundler

AWSにrails4とか – rvm

rvmインストール 当たり前ですが、rubyのインストールは時間がかかります。

bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer" target="_blank">https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

source /etc/profile.d/rvm.sh
rvm get latest
rvm list known
rvm install 1.9.3
rvm install 2.0.0
rvm list 
rvm –default 1.9.3
rvm use 2.0.0

AWSにrails4とか – 事前準備

AWSのamazonlinuxのrvmでrubyとrails4インストールしてみました。 めんどくさいので全部root

yum -y install git 

yum -y install make 
yum -y install gcc 
yum -y install gcc-c++ 
yum -y install zlib-devel 
yum -y install openssl-devel 
yum -y install httpd-devel 
yum -y install curl 
yum -y install curl-devel 
yum -y install readline-devel 
yum -y install tk-devel
yum –enablerepo=epel -y install libyaml-devel