24
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ruby 2.0.0-p247 + Rails 4.0.0 + minimum-omniauth-scaffold

Last updated at Posted at 2013-07-13

アプリ名

belem

バージョン

  • Rubyバージョン
ruby -v
----------
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
----------
  • Railsバージョン
rails -v
----------
Rails 4.0.0
----------

App Setup

作業ディレクトリ移動

cd ~/labo

Railsアプリ作成

  • 設定
cat ~/.railsrc
----------
--skip-bundle
--skip-test-unit
----------
  • アプリ作成
rails new belem
----------
Using --skip-bundle --skip-test-unit from /Users/shu/.railsrc
      create  
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/assets/images/.keep
      create  app/mailers/.keep
      create  app/models/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/bundle
      create  bin/rails
      create  bin/rake
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  lib
      create  lib/tasks
      create  lib/tasks/.keep
      create  lib/assets
      create  lib/assets/.keep
      create  log
      create  log/.keep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/robots.txt
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.keep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.keep
----------
cd belem

Gemfile/Gemインストール

  • プロジェクトオープン
subl .

Gemfile

ruby '2.0.0'

gem 'haml-rails'
gem 'minimum-omniauth-scaffold'
gem 'action_args'
gem 'html5_validators'
gem 'puma'
gem 'kaminari'
gem 'rails_config'
gem 'tapp'
gem 'awesome_print'
gem "exception_notification", "~> 4.0.0.rc1"
gem 'i18n_generators'

group :development do
  gem 'pry-rails'
  gem "rails-erd"
  gem 'binding_of_caller'
  gem "erb2haml"
  gem 'quiet_assets'
end

group :development, :test do
  gem "sqlite3"
  gem 'rspec-rails'
end

group :production do
  gem 'rails_12factor'
  gem 'pg'
  gem 'newrelic_rpm'
end

# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
bundle install --without production
bundle update

OmniAuth用スキャフォールド作成

rails g minimum:omniauth:scaffold

ローカル用キー設定

※Twitterキー作成後config/settings.local.ymlへ設定

cat config/settings.local.yml

New Relic準備

curl https://raw.github.com/gist/2253296/newrelic.yml > config/newrelic.yml
cat config/newrelic.yml

アプリ名設定

vi config/settings.yml
# アプリケーション名
app_name: "Belem"

# プログラマTwitterID
programmer_twitter_id: "my_twitter_id"

マイグレーション

rake db:migrate

Haml化

dhl/erb2haml

  • erbを消す
rake haml:replace_erbs
  • erbを残す
rake haml:convert_erbs

Railsサーバ起動

rails s puma
----------
=> Booting Puma
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Puma 2.3.2 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://0.0.0.0:3000
----------

ローカルサイト確認

http://0.0.0.0:3000/


GitHub

GitHubリポジトリ作成

https://github.com/repositories/new

Repository name
[ belem ]
    
Description (optional)
[ (description.) ]
    
※チェック無し:Initialize this repository with a README
Add .gitignore: None
git init && git add . && git commit -m "First commit"

GitHubリポジトリアドレス

HTTP => SSH

GitHubリポジトリプッシュ

git remote add origin git@github.com:MY_NAME/belem.git
git push -u origin master

GitHubリポジトリ

https://github.com/shu0115/belem


Heroku

Herokuアプリ作成

heroku create belem
----------
Creating belem... done, region is us
http://belem.herokuapp.com/ | git@heroku.com:belem.git
Git remote heroku added
----------

Herokuプッシュ

git push heroku master

Twitterアプリ登録

Twitter Dev

Name: *
[ Belem ]

Description: *
[ (description.) ]

WebSite: *
[ https://belem.herokuapp.com/ ]

Callback URL:
[ https://belem.herokuapp.com/ ]

※必須マークが無いが「Callback URL:」も登録しないと動かない

Heroku環境変数設定

※Production用Twitterキーを作成し環境変数に設定

heroku config:set TWITTER_KEY=********** TWITTER_SECRET=******************************

Heroku設定確認

heroku config | grep "TWITTER"
-----
TWITTER_KEY:                **********
TWITTER_SECRET:             ******************************
-----

Herokuタイムゾーン設定

heroku config:add TZ=Asia/Tokyo

Herokuアドオンインストール(FREE-Only)

heroku addons:add pgbackups:auto-month
heroku addons:add newrelic:standard
heroku addons:add scheduler:standard
heroku addons:add papertrail:choklad
heroku addons:add loggly:mole
heroku addons:add logentries:tryit

Herokuアドオン確認

heroku addons
----------
=== belem Configured Add-ons
heroku-postgresql:dev  HEROKU_POSTGRESQL_CRIMSON
logentries:tryit
loggly:mole
newrelic:standard
papertrail:choklad
pgbackups:auto-month
scheduler:standard
----------

Herokuマイグレーション

heroku run rake db:migrate
----------
Running `rake db:migrate` attached to terminal... up, run.9640
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.6
==  CreateUsers: migrating ====================================================
-- create_table(:users)
   -> 0.0922s
==  CreateUsers: migrated (0.0935s) ===========================================
----------

Herokuページオープン

heroku open

Heroku公開サイト

アイドル防止(NewRelic)

Heroku Apps => Add-ons => New Relic Standard

24
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?