参考サイト
カスタマイズ備忘録
- app/views/shared/_breadcrumbs.html.haml
- if elements.present? %ul.breadcrumb - elements[0..-2].each do |element| %li - if element.path.present? = link_to element.name, element.path - else = element.name %li = elements.last.name
- if elements.present? %ul.breadcrumb - elements[0..-2].each do |element| %li - if element.path.present? = link_to element.name, element.path - else = element.name %li = elements.last.name
$ rails g kaminari:views bootstrap -e haml /home/vagrant/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/json/common.rb:155:in `initialize': no implicit conversion of StringIO into String (TypeError) from /home/vagrant/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/json/common.rb:155:in `new' from /home/vagrant/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/json/common.rb:155:in `parse' from /home/vagrant/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.0/lib/active_support/json/decoding.rb:26:in `decode' from /home/vagrant/.rvm/gems/ruby-2.1.1/gems/kaminari-0.15.1/lib/generators/kaminari/views_generator.rb:99:in `block in get_files_in_master (省略)
gem 'kaminari'
gem 'kaminari', github: 'amatsuda/kaminari'
$ bundle install
$ rails g kaminari:views bootstrap -e haml downloading app/views/kaminari/_first_page.html.haml from kaminari_themes... create app/views/kaminari/_first_page.html.haml downloading app/views/kaminari/_gap.html.haml from kaminari_themes... create app/views/kaminari/_gap.html.haml downloading app/views/kaminari/_last_page.html.haml from kaminari_themes... create app/views/kaminari/_last_page.html.haml downloading app/views/kaminari/_next_page.html.haml from kaminari_themes... create app/views/kaminari/_next_page.html.haml downloading app/views/kaminari/_page.html.haml from kaminari_themes... create app/views/kaminari/_page.html.haml downloading app/views/kaminari/_paginator.html.haml from kaminari_themes... create app/views/kaminari/_paginator.html.haml downloading app/views/kaminari/_prev_page.html.haml from kaminari_themes... create app/views/kaminari/_prev_page.html.haml
備忘録としてまとめておきます。
Rails 4.1.0
get '*path' => 'application#render_404'
unless Rails.application.config.consider_all_requests_local rescue_from ActiveRecord::RecordNotFound, :with => :render_404 rescue_from ActionController::UnknownAction, :with => :render_404 rescue_from ActionController::RoutingError, :with => :render_404 rescue_from Exception, :with => :render_500 end def render_404(exception = nil) if exception logger.info "Rendering 404 with exception: #{exception.message}" end render :file => "#{Rails.root}/public/404.html", :status => :not_found, :layout => false, :content_type => 'text/html' end def render_500(exception = nil) if exception logger.info "Rendering 500 with exception: #{exception.message}" end render :file => "#{Rails.root}/public/500.html", :status => :internal_server_error, :layout => false, :content_type => 'text/html' end
これがデフォルトなのかわからないけど、参考になれば。
1年以上待ちに待ったTagsがようやくTrac1.0に、
対応したらしいので、早速インストールしてみました!
2014年04月06日にリリースされてました。
前回のコメントは13ヶ月前だったのに、急に対応されて歓喜!
$ sudo easy_install https://trac-hacks.org/svn/tagsplugin/tags/0.7
Downloading https://trac-hacks.org/svn/tagsplugin/tags/0.7 Doing subversion checkout from https://trac-hacks.org/svn/tagsplugin/tags/0.7 to /tmp/easy_install-7cZaeN/0.7 Processing 0.7 Running setup.py -q bdist_egg --dist-dir /tmp/easy_install-7cZaeN/0.7/egg-dist-tmp-wTZMvo unrecognized .svn/entries format; skipping . unrecognized .svn/entries format in zip_safe flag not set; analyzing archive contents... Removing TracTags 0.6 from easy-install.pth file Adding TracTags 0.7-r0 to easy-install.pth file Installed /usr/lib/python2.6/site-packages/TracTags-0.7_r0-py2.6.egg Processing dependencies for TracTags==0.7-r0 Finished processing dependencies for TracTags==0.7-r0
[tags] revisable_realms = wiki [components] tractags.* = enabled
$ sudo trac-admin /var/trac/[プロジェクト名] upgrade アップグレードが終了しました。 次のコマンドを実行すると Trac のドキュメントをアップグレードできます: trac-admin /var/trac/[プロジェクト名] wiki upgrade $ sudo trac-admin /var/trac/[プロジェクト名] wiki upgrade
$ sudo chown apache:apache -R /var/trac/
$ sudo service httpd restart
Vagrantで使用するCentOSのboxをWindows7でVeeweeを使って作成 - 迷い家の白猫 技術部 で作成したboxを使って環境構築
Windows 7 Professional 64bit SP1
VirtualBox 4.3.6
Vagrant 1.4.3
コマンドプロンプトを起動させ、以下のコマンドを実行。
> vagrant plugin install sahara > vagrant plugin install vagrant-vbguest
プラグインがインストールできていることを確認
> vagrant plugin list sahara (0.0.16) vagrant-vbguest (0.10.0)
任意の作業用フォルダを作成しそこで以下のコマンドをコマンドプロンプトを起動させ実行。
> vagrant box add 'CentOS-6.3-x86_64_dev' [絶対パスor相対パス]/CentOS-6.3-x86_64.box
作業フォルダ内で Shiftキー+右クリックで表示されるメニューの「コマンド ウィンドウをここで開く(W)」ですぐに開けます。(因みに、Vistaからの機能)
> vagrant init 'CentOS-6.3-x86_64_dev'
$ sudo su - # echo exclude=kernel* centos* >> /etc/yum.conf # yum update -y # exit
$ sudo yum install -y vim-enhanced
$ \curl -sSL https://get.rvm.io | bash -s stable --autolibs=enabled --ruby $ source ~/.profile $ source /home/vagrant/.rvm/scripts/rvm
$ sudo yum install -y git $ git --version git version 1.7.1
tigとは、CUIなGitブラウザ
$ sudo rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
$ sudo yum install -y tig $ tig --version tig version 1.2
$ git config --global user.email "you@example.com" $ git config --global user.name "Your Name" $ git config --global push.default current $ git config --global color.ui true
$ sudo /sbin/service iptables stop $ sudo /sbin/chkconfig iptables off
開発環境のため停止。80,443ポートは初期状態は閉じています。
必要な場合、別途設定する。
$ sudo yum install -y mysql-server mysql-devel $ sudo /etc/init.d/mysqld start $ sudo /sbin/chkconfig mysqld on
$ mysql_secure_installation Enter current password for root (enter for none): [ENTER] ... Set root password? [Y/n] [ENTER] New password: [任意のパスワード] Re-enter new password: [任意のパスワード] ... Remove anonymous users? [Y/n] Y ... Disallow root login remotely? [Y/n] Y ... Remove test database and access to it? [Y/n] Y ... Reload privilege tables now? [Y/n] Y ... Thanks for using MySQL!
CentOS 6.3 64bit
他のバージョンも同じ感じで作成できます。
Windows 7 Professional 64bit SP1
msysgit 1.8.5.2
VirtualBox 4.3.6
Vagrant 1.4.3
Ruby 2.0.0-p353
以下から最新版をダウンロードする
http://code.google.com/p/msysgit/downloads/list
ダウンロードしたときは「Git-1.8.5.2-preview20131230.exe」が最新でした。
インストールを進めると以下のダイアログが表示されますので、
「Run Git and included Unix tools from the Windows Command Prompt」を選択してインストールします。
以下から最新版をダウンロードする
https://www.virtualbox.org/wiki/Downloads
ダウンロードしたときは、「VirtualBox-4.3.6-91406-Win.exe」が最新でした。
特に気にせずインストールを進める。
以下から最新版をダウンロードする
http://www.vagrantup.com/downloads.html
ダウンロードしたときは、「Vagrant_1.4.3.msi」が最新でした。
Vagrantインストール後、再起動を要求されるので再起動します。
以下から最新版をダウンロードする
http://rubyinstaller.org/downloads/
ダウンロードしたときは、
Ruby:「rubyinstaller-2.0.0-p353.exe」
DevKit:「DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe」
が最新でした。
因みに32bit版をダウンロードしました。
64bit版でも問題なかったですが、別件で、使おうとしたnokogiriが64bit版に対応してなかったから;;
DevKitは、任意の場所に展開します。今回は、「C:\DevKit」に展開します。
コマンドプロンプトを開き以下のコマンドを実行し、DevKitをインストールします。
> cd C:\DevKit > ruby dk.rb init > ruby dk.rb install
改行コードの問題を減らすための対応。
チェックアウトするときに行末の LF を CRLF に自動変換されないように無効にします。
> git config --global core.autocrlf false
作業フォルダは適当に。
CentOSのISOをダウンロードするので、Cドライブ以外が良いかと思います。
> git clone git://github.com/jedi4ever/veewee.git
> cd veewee > bundle install
これで、Veeweeを使える環境が整いました。
> bundle exec veewee vbox templates
今回は、CentOS 6.3 64bit版のBoxを作ります。
> bundle exec veewee vbox define 'CentOS-6.3-x86_64' 'CentOS-6.3-x86_64-minimal'
上記を実行すると、Veeweeフォルダ配下に definitions/CentOS-6.3-x86_64 が作成されます。
言語とキーボードの設定やSELinuxの設定などなど
自分は以下に変更しています。
lang ja_JP.UTF-8 keyboard jp106 timezone --utc Asia/Tokyo
SELinuxが有効になっている場合は、無効にしておく。(CentOS 5.9のboxを作った時に行った設定)
selinux --enforcing
上記を以下のように。
selinux --disabled
ファイル開いて書き換えるのが面倒なので、sedコマンドで置換したりしてます。
> cd definitions\CentOS-6.3-x86_64 > cp -ip ks.cfg ks.cfg.bak > sed -i -e "s/lang en_US\.UTF-8/lang ja_JP\.UTF-8/g" ks.cfg > sed -i -e "s/keyboard us/keyboard jp106/g" ks.cfg > sed -i -e "s/timezone UTC/timezone --utc Asia\/Tokyo/g" ks.cfg
このファイルで仮想マシンのディスクサイズやメモリ、OSのイメージファイルのダウンロード先、
インストール作業自体のタイムアウトや標準のインストールが終わったあとの追加のインストール作業の設定が可能です。
ISOファイルをダウンロードするミラーサーバーを以下に変更
http://ftp.riken.jp/Linux/centos/
デフォルトだと、ISOファイルが削除されているので変更は必須かと。
あと上記のミラーサーバーだと古いバージョンのCentOSのISOも残してるので重宝してますw
不要なインストールはここで、コメントアウトする。
:postinstall_files => [ "base.sh", "chef.sh", "puppet.sh", "vagrant.sh", "virtualbox.sh", #"vmfusion.sh", "cleanup.sh", "zerodisk.sh" ],
puppetクライアントのインストールが必要がない場合は、
#"puppet.sh",
のようにします。
これもsedコマンドで置換したりしてます。
> cp -ip definition.rb definition.rb.bak > sed -i -e "s/www\.mirrorservice\.org\/sites\/mirror\.centos\.org/ftp\.riken\.jp\/Linux\/centos/g" definition.rb > sed -i -e "s/\"puppet\.sh\",/#\"puppet\.sh\",/g" definition.rb
デフォルトで記載されているものを削除、以下に修正する。
cd /tmp wget http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz || fail "Could not download Ruby source" tar xzvf ruby-2.0.0-p353.tar.gz cd ruby-2.0.0-p353 ./configure make && make install cd /tmp rm -rf /tmp/ruby-2.0.0-p353 rm /tmp/ruby-2.0.0-p353.tar.gz ln -s /usr/local/bin/ruby /usr/bin/ruby # Create a sym link for the same path ln -s /usr/local/bin/gem /usr/bin/gem # Create a sym link for the same path
デフォルトのままでは、ruby 1.8.7 がインストールされます。
chef.shでインストールされる chef が ruby 1.8.7 で使えなくなって失敗したため、Ruby 2.0.0 をインストールしました。
sedコマンドで置換した時にフォルダ移動したので前のフォルダに戻る。
cd ../../
> bundle exec veewee vbox build 'CentOS-6.3-x86_64'
途中ISOファイルをダウンロードするか聞かれるので、 yes を入力し Enter を押します。
Download? (Yes/No) yes[Enter]
ISOファイルがダウンロードされ、自動的に VirtualBox のウインドウが起動し、OSのインストールが進んでいきます。
仮想マシンで64bitのOSが動作できない場合、途中で失敗します。しかしコマンドプロンプトではエラーが表示されず、中々返ってこないので、
VirtualBox のウインドウを確認してるとすぐ気づきます。
あまりないけど、1回あったので記載しておきます。
このビルドは結構時間が掛かります。
ISOファイルは、Veeweeフォルダ直下のisoフォルダにダウンロードされています。
> bundle exec veewee vbox export 'CentOS-6.3-x86_64'
上記のコマンドで、起動しているCentOSに、シャットダウンコマンドが送られるので、
VirtualBox のウインドウでCentOSにログインし、シャットダウンする必要はありません。
エクスポートが完了すると、Veeweeフォルダ直下に以下のboxファイルができます。
CentOS-6.3-x86_64.box
Mac OS X : 10.8.4
VMWare Fusion : 5.0.3
以下から最新版をダウンロードする(当時 v1.3.1)
http://downloads.vagrantup.com/
$ vagrant -v Vagrant 1.3.1
Vagrantbox.es から仮想イメージをダウンロードします。
VMware用のCentOS 6.4 x64 を使用します。
titleは、centos64としてます。
$ vagrant box add centos64 https://dl.dropbox.com/u/5721940/vagrant-boxes/vagrant-centos-6.4-x86_64-vmware_fusion.box
Vagrantは、デフォルトでVirtualboxを使用して仮想マシンを立ち上げるそうです。
VMWare Fusionを使用する場合は、プラグインを購入する畢業があるみたいです。
以下のサイトで購入することができます。
http://www.vagrantup.com/vmware#buy-now
価格は、$79
VMWare Fusionより高いとは。。。
VMWare Fusionを選択し、必要情報を入力、クレジットカードの情報を入力して決済すれば入力したメールアドレスにlicense.licというファイルが届きます。
$ vagrant plugin install vagrant-vmware-fusion $ vagrant plugin license vagrant-vmware-fusion license.lic
$ vagrant init centos64
デフォルトでは、仮想ライブラリからでは、管理できないためGUIで管理できるようにします。
Vagrantfileへ以下を追記します。
$ vim Vagrantfile
config.vm.provider "vmware_fusion" do |v| v.gui = true end
$ vagrant up --provider=vmware_fusion
$ vagrant ssh
exit