Note

rails 自分的まとめ: 初期設定編

Railsの初期設定についてまとめる

Railsの自分的初期設定についてまとめる。
これから作成する場合にほぼ間違いなくすると思うのでまとめておきたい。

rails new

$ rails new

日本語化

rails日本語化
http://qiita.com/yutackall/items/0ff97132f31e5bacbf00

haml使用のため

Gemfile

gem 'haml-rails'

$ bundle install $ rails generate haml:application_layout convert $ rails generate haml:application_layout convert

bootswatch 使用

# Gemfile gem 'twitter-bootswatch-rails', '~> 3.1.1' gem 'twitter-bootswatch-rails-helpers' gem 'execjs' gem 'less-rails' gem 'therubyracer', platforms: :ruby

$ bundle install $ rails g bootswatch:install simplex $ rails g bootswatch:import simplex $ rails g bootswatch:layout simplex

app/assets/stylesheets/application.css に

*= require simplex/loader *= require simplex/bootswatch

を追加

app/assets/javascripts/application.js に

//= require simplex/loader //= require simplex/bootswatch

を追加

あとは https://bootswatch.com/simplex/ のやつ適当に組み合わせる
独自にCSS入れたいときはapp/assets/stylesheets/simplex/ の中にxxxx.lessファイルを置いてそのなかに書いていく。

scaffold

$ rails g scaffold <name> <column>:<type>

使用可能な型
string 文字列
text 長い文字列
integer 整数
float 浮動小数
decimal 精度の高い小数
datetime 日時
timestamp より細かい日時
time 時間
date 日付
binary バイナリデータ
boolean Boolean型