SEARCH

Linux Install

Android

Linux Tools

Linux AV

Linux Memo

WINDOWS

PROGRAM

動画 Memo

音楽 Memo

モバイルアプリ Memo

FILE FORMAT

PROTOCOL

DEVICE

BookMark

その他


win-rails4   

rails for win new project

project の作成

eclipse で rails プロジェクトを生成
cd 【projectdir】
rm -rf * 
rails new ./ -d postgresql
cp -r bin script
createuser -U postgres -P 【projectname】
createdb -U postgres 【projectname】

config/database.yml

database を 【projectname】に

config/boot.rb

begin
   File.delete(File.expand_path('../../tmp/pids/server.pid',  __FILE__))
rescue
   # Do nothing
end

session(active record)

Gemfile

gem 'activerecord-session_store', github: 'rails/activerecord-session_store'
bundle install
rails g active_record:session_migration
rake db:migrate

config/initializers/session_store.rb

【appname】::Application.config.session_store :active_record_store

どこかでセッションをクリアする

ActiveRecord::SessionStore::Session.delete_all([ 'updated_at < ?', 30.minutes.ago ])

devise(ユーザ管理)

Gemfile

gem 'devise'
bundle install 
rails g devise:install
rails generate scaffold User --skip-migration
rails generate devise User
rake db:migrate
rails g devise:views

attribute の追加

rails g migration AddNameToUsers name:string
rake db:migrate

app/controllers/application_controller.rb

 before_filter :configure_permitted_parameters, if: :devise_controller?

 private
 def configure_permitted_parameters
   devise_parameter_sanitizer.for(:sign_up) do |u|
     u.permit(:name, :password, :password_confirmation, :email ,:current_password)
   end
   devise_parameter_sanitizer.for(:account_update) do |u|
     u.permit(:name, :password, :password_confirmation, :email ,:current_password)
   end
 end