Gemfileに下記の2行を追加。
gem 'capybara'
gem 'launchy'
bundle installを実行。下記のようなエラーがでる。
bundle install
-- 省略 --
Installing nokogiri (1.5.0) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... no
-----
libxslt is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/ruby
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.0 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.0/ext/nokogiri/gem_make.out
An error occured while installing nokogiri (1.5.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.5.0'` succeeds before bundling.
調べた結果、libxslt-develが必要らしいので、インストール。
yum install libxslt-devel
再度bundle installを実行。
bundle install
今度はうまくいった。
2012年2月3日金曜日
2012年2月1日水曜日
Rails3でデータベースの日付を日本時間にする方法
Rails3では、データベースに日付を格納するときにUTCとするため、
日本時間のみを扱いたい場合はちょっと不便。
下記の方法で解決できる。
(参考URL: http://blog.libero-tecnologia.net/?p=40)
config/application.rbに下記2行を追加
config.time_zone = ‘Tokyo’
config.active_record.default_timezone = :local
日本時間のみを扱いたい場合はちょっと不便。
下記の方法で解決できる。
(参考URL: http://blog.libero-tecnologia.net/?p=40)
config/application.rbに下記2行を追加
config.time_zone = ‘Tokyo’
config.active_record.default_timezone = :local
2012年1月8日日曜日
Rails3.0 bundle install時のsqliteエラー解決方法
bundle install時に、次のようなエラーが出る場合がある。
An error occured while installing sqlite3 (1.3.5), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.5'` succeeds before bundling.
適切なバージョンのsqliteをインストールしていないために、このエラーが起きるようだ。
yumでsqliteをインストールしてみたが、インストールされるバージョン(3.3)が古いために解決できなかった。
sqlite3.5以上のソースをダウンロードしてインストールしてみた。
**** RPM package creation selected ***
**************************************
This package will be built according to these values:
1 - Summary: [ Package created with checkinstall 1.6.0 ]
2 - Name: [ sqlite-autoconf ]
3 - Version: [ 3070900 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ sqlite-autoconf-3070900 ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ sqlite-autoconf ]
Enter a number to change any of them or press ENTER to continue: 2 #Nameを指定する
Enter new name:
>> sqlite
This package will be built according to these values:
1 - Summary: [ Package created with checkinstall 1.6.0 ]
2 - Name: [ sqlite ]
3 - Version: [ 3070900 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ sqlite-autoconf-3070900 ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ sqlite-autoconf ]
Enter a number to change any of them or press ENTER to continue: 3 #Versionを指定する
Enter new version:
>> 3.7.9
This package will be built according to these values:
1 - Summary: [ Package created with checkinstall 1.6.0 ]
2 - Name: [ sqlite ]
3 - Version: [ 3.7.9 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ sqlite-autoconf-3070900 ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ sqlite-autoconf ]
Enter a number to change any of them or press ENTER to continue: #Enterを押下
rpm -ivh /usr/src/redhat/RPMS/i386/sqlite-3.7.9-1.i386.rpm
sqliteがインストールされたことを確認する。
sqlite3
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .q
Railsのbundle installを実行してみる。
bundle install
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
なんとかうまくいった。ほっと一息。
An error occured while installing sqlite3 (1.3.5), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.5'` succeeds before bundling.
適切なバージョンのsqliteをインストールしていないために、このエラーが起きるようだ。
yumでsqliteをインストールしてみたが、インストールされるバージョン(3.3)が古いために解決できなかった。
yum install sqlite-devel #これではダメ!
sqlite3.5以上のソースをダウンロードしてインストールしてみた。
wget http://www.sqlite.org/sqlite-autoconf-3070900.tar.gz
tar zxvf sqlite-autoconf-3070900.tar.gz
cd sqlite-autoconf-3070900
./configure
tar zxvf sqlite-autoconf-3070900.tar.gz
cd sqlite-autoconf-3070900
./configure
make
checkinstall -R --fstrans=no --exclude=/selinux
****************************************** RPM package creation selected ***
**************************************
This package will be built according to these values:
1 - Summary: [ Package created with checkinstall 1.6.0 ]
2 - Name: [ sqlite-autoconf ]
3 - Version: [ 3070900 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ sqlite-autoconf-3070900 ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ sqlite-autoconf ]
Enter a number to change any of them or press ENTER to continue: 2 #Nameを指定する
Enter new name:
>> sqlite
This package will be built according to these values:
1 - Summary: [ Package created with checkinstall 1.6.0 ]
2 - Name: [ sqlite ]
3 - Version: [ 3070900 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ sqlite-autoconf-3070900 ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ sqlite-autoconf ]
Enter a number to change any of them or press ENTER to continue: 3 #Versionを指定する
Enter new version:
>> 3.7.9
This package will be built according to these values:
1 - Summary: [ Package created with checkinstall 1.6.0 ]
2 - Name: [ sqlite ]
3 - Version: [ 3.7.9 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ sqlite-autoconf-3070900 ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ sqlite-autoconf ]
Enter a number to change any of them or press ENTER to continue: #Enterを押下
rpm -ivh /usr/src/redhat/RPMS/i386/sqlite-3.7.9-1.i386.rpm
sqliteがインストールされたことを確認する。
sqlite3
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .q
Railsのbundle installを実行してみる。
mkdir work_rails_check
cd work_rails_check/
rails new checkapp
cd checkapp/bundle install
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
なんとかうまくいった。ほっと一息。
2012年1月7日土曜日
CentOSにRails3.0を導入(CheckInstall使用)
今回、Rails3の導入にCheckInstallというツールを利用する。
CheckInstallの導入方法
以下Railsインストール手順
あらかじめgccをインストール
yum install gcc
あらかじめrpm-buildをインストール
yum install rpm-build
あらかじめzlib-develをインストール
yum install zlib-devel
あらかじめ必要なパッケージをインストール
yum install gcc gcc-c++ make perl zlib-devel openssl-devel readline-devel libxml2-devel bzip2-devel unzip libjpeg-devel libpng-devel freetype-devel rpm-build -y
Rubyソースコードをダウンロード(ruby-1.9.3-p0だと、Gemがうまく動作しない)
アーカイブを展開
コンパイルしてCheckInstallでRPMパッケージ化
ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
Gemのバージョン確認。
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
Railsインストール。(バージョン3.1.2だと、Railsバージョン確認でエラーが出る)
gem install rails -v 3.0
Railsバージョン確認
rails -v
Rails 3.0.0
以上でRailsのインストールが完了する。
できればRails3.1を使いたかったのだが、今回は妥協した。
CheckInstallの導入方法
以下Railsインストール手順
あらかじめ必要なパッケージをインストール
yum install gcc gcc-c++ make perl zlib-devel openssl-devel readline-devel libxml2-devel bzip2-devel unzip libjpeg-devel libpng-devel freetype-devel rpm-build -y
Rubyソースコードをダウンロード(ruby-1.9.3-p0だと、Gemがうまく動作しない)
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.bz2
アーカイブを展開
tar xjf ruby-1.9.2-p290.tar.bz2
コンパイルしてCheckInstallでRPMパッケージ化
cd ruby-1.9.2-p290
./configure
make
make
checkinstall -R --fstrans=no
・・・途中でいろいろ聞かれるが、EnterキーでOK
RPMパッケージからrubyをインストール
cd /usr/src/redhat/RPMS/i386/
rpm ivh ruby-1.9.2-p290-1.i386.rpm
Rubyのバージョンを確認。rpm ivh ruby-1.9.2-p290-1.i386.rpm
ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
Gemのバージョン確認。
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
Railsインストール。(バージョン3.1.2だと、Railsバージョン確認でエラーが出る)
gem install rails -v 3.0
Railsバージョン確認
rails -v
Rails 3.0.0
以上でRailsのインストールが完了する。
できればRails3.1を使いたかったのだが、今回は妥協した。
2011年10月10日月曜日
Railsメモ:多対多の関連を利用したときにNameError: uninitialized constant
多対多の関連を設定したんだけど、データの読み出しがうまくいかない・・・
ソースはこんな感じ。
ソースはこんな感じ。
2011年8月23日火曜日
Rails 3.0.5 scaffoldで作成させるアクションメソッドの一覧(REST URL)
Railsでは、[リソース名][アクション名]という規則でURLを作成することが推奨されている。
scaffoldでアプリケーションを作成すると、このルールに則ったアクションが実装される。
各アクション名とその意味は下記のとおり。
scaffoldでアプリケーションを作成すると、このルールに則ったアクションが実装される。
各アクション名とその意味は下記のとおり。
アクション | 動作 |
---|---|
index | 一覧画面を表示 |
show | 個別詳細画面を表示 |
new | 新規登録画面を表示 |
create | 新規登録画面の入力を受けて登録処理 |
edit | 編集画面を表示 |
update | 編集画面の入力を受けて更新処理 |
destroy | 一覧画面で指定されたデータを削除処理 |
2011年2月8日火曜日
Rails3 「sqlite3.dllが見つかりません」 の対処法
環境:
Windows7 Home Premium
Ruby 1.9.2
Rails 3.0.3
操作(入力コマンド):
rails server
現象:
ダイアログに「sqlite3.dllが見つかりません」と表示される
対処法:
Rubyインストールディレクトリのbin配下に、sqlite3.dllを配置する。
対処例:
C:\Ruby192\bin このディレクトリにsqlite3.dllを配置
補足:
sqlite3.dllダウンロード元
http://www.dbonline.jp/sqliteinstall/install/index3.html
Windows7 Home Premium
Ruby 1.9.2
Rails 3.0.3
操作(入力コマンド):
rails server
現象:
ダイアログに「sqlite3.dllが見つかりません」と表示される
対処法:
Rubyインストールディレクトリのbin配下に、sqlite3.dllを配置する。
対処例:
C:\Ruby192\bin このディレクトリにsqlite3.dllを配置
補足:
sqlite3.dllダウンロード元
http://www.dbonline.jp/sqliteinstall/install/index3.html
登録:
投稿 (Atom)