Skip to content

Instantly share code, notes, and snippets.

@maechabin
Created February 1, 2013 12:21
Show Gist options
  • Save maechabin/4690997 to your computer and use it in GitHub Desktop.
Save maechabin/4690997 to your computer and use it in GitHub Desktop.
rvm : rubyのバージョンマネージャー
ruby:
gemset:
rails gem:
-------
xcode
java
homebrew
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
RVM
\curl -L https://get.rvm.io | bash -s stable --ruby
-------
rvm use 1.9.3
rvm gemset create todo
rvm gemset list
rvm use 1.9.3@todo
gem install rails
rails new todo -T --skip-bundle #プロジェクトをつくる -T→テストユニットをはずす
touch ./.rvmrc
vim ./.rvmrc
rvm use 1.9.3@todo # ←記述
:wq
cd ..
cd todo → yes
vim Gemfile
therubyracer # ←コメントアウトはずす
:wq
bundle install #rubyracer注意
vim ./Gemfile.lock #どのバージョンがインストールされたか
rails s
→localhost:3000にアクセス
rails g scaffold tasks body:string status:boolean #複数形にする
rails s
→localhost:3000/tasks/ #DBがないのでエラー
rake db:migrate #テーブル作成
rails s
→localhost:3000/tasks/
vim ./Gemfile
gem 'therubyracer', :platforms=>:ruby
gem 'less'
gem 'less-rails'
gem 'twitter-bootstrap-rails'
#gem 'jquery-rails'の前に記述
:wq
bundle install
rails generate bootstrap:install less
-----
todo > app > assets > stylesheets > scaffold.css削除
todo > public > routes.rb
root :to => 'tasks#index'
---
Gemfile
gem 'haml'
# gem 'jquery-rails'の後に記述
bundle install
---
application.html.erb
※command+shift+p haml
#hamlのシンタックスを適用
!!! #html5の宣言
%html
%head
%title todo
=stylesheet_link_tag "application"
, :media => "all"
=csrf_meta_tags
%body
.navber
.navber-inner
%a.brand ToDo
%ul.nav
%li
%a{ :href => "#" } home
%li menu1
%li menu2
.container
=yield
application.html.erb → application.html.hamlに変更
_form.html.erb #1
= form_for(@task) do |f|
.field
=f.label :body
=f.text_field :body
.field
=f.label :status
=f.label :status
.actions
=f.submit
_form.html.erb #2
= form_for(@task, :html => { :class => "form-horizontal"}) do |f|
.control-group
.control-label=f.label :body
.controls=f.text_field :body
.control-group
.control-label=f.label :status
.controls=f.label :status
.control-group
.controls=f.submit :class => "btn"
_form.html.erb → _form.html.hamlに変更
参考
http://twitter.github.com/bootstrap/components.html
view > tasks
----
rake routes #uri表示
rails c #コンソール
> Task
> Task.all
> @task.body = "chinco"
> @task.status = false
> @task
> @task.save
> Task.find(2)
> Task.find_by_body("chinco")
> Task.find_by_body(false)
> Task.where(:status => false)
>Task.find_all_by_status(false)
---
git init #todoの中で
git status
git add .
git commit -am "Initial commit"
git branch
heroku login
heroku create
git remote -v
vim ./Gemfile
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'ps'
gem 'thin'
end
bundle install
git status
git add .
git status
git commit -am "Impl gems"
git push heroke master
heroke open
heroke logs
heroke run rake db:migrate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment