マルニカ。
Ruby周辺備忘録。たまに日記。
Ads by Google
上記の広告は1ヶ月以上更新のないブログに表示されています。
新しい記事を書く事で広告が消せます。

.svnを再帰的に削除するコマンド
■Windows
for /f "tokens=*" %d in ('dir /b/s/a:dh *.svn') do rmdir /q/s "%d"

■Linux系
find . -name .svn -exec rm -fr {} \;
Lighttpd+FCGI
参考
http://centos.oss.sc/ruby/apache_lighttpd_rails/

wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
make install

yum install ruby-devel
gem install fcgi

yum --enable=rpmforge install lighttpd
yum --enable=rpmforge install lighttpd-fastcgi

chown -R lighttpd. /path/to/rails
chmod +x /path/to/rails/public/dispatch.*
Linux パスを設定するメモ。
■パスを通す
$ PATH=$PATH:/usr/local/pgsql/bin
$ export PATH

※↑これだけだと、毎回パスを通す必要がある。

■ログイン時に自動的にパスを通す
ホーム直下の.bash_profileを編集
$ vi .bash_profile
--
PATH=$PATH:/usr/local/pgsql/bin
export PATH

--参考--
http://pocketstudio.jp/linux/?%A5%D1%A5%B9(PATH)%A4%CE%B3%CE%C7%A7%A4%C8%C0%DF%C4%EA%CA%FD%CB%A1%A4%CF%A1%A9
RailsのテストでPostGISのGeometry型を扱うメモ。
問題が解決したので改めてメモしなおします。

実行環境:CentOS5.2, Rails2.1, PostgreSQL8.3.3
----
0.PostGISはインストール済み。
PostGISインストールメモ。参照

1.postgres-prとGeoRubyをインストール。
gem install postgres-pr
gem install GeoRuby


2.railsプロジェクトを作成。(「sample」プロジェクトとする。)
rails sample --database=postgresql
cd sample


3.Spatial Adapter for Railsプラグインをインストール。
ruby script/plugin install svn://rubyforge.org/var/svn/georuby/SpatialAdapter/trunk/spatial_adapter
または
ruby script/plugin install http://georuby.rubyforge.org/svn/SpatialAdapter/trunk/spatial_adapter/

4.開発用とテスト用データベースを作る。
su - postgres # posturesユーザに移動
createdb sample_development  #開発用 development
createlang plpgsql sample_development
psql -d sample_test -f /usr/share/lwpostgis.sql
psql -d sample_test -f /usr/share/spatial_ref_sys.sql

createdb sample_test  #テスト用 test


☆5.テスト用DBの初期化方法をSQLに変更する
(config/environment.rb の以下のコメントをはずす。)
config.active_record.schema_format = :sql


6.config/database.ymlを適宜編集。

7.諸々ソースをcaffoldで生成する。
ruby script/generate scaffold table_point data:string geom:point


8.db/migrate/*_create_table_points.rbを編集する。
class CreateTablePoints < ActiveRecord::Migration
def self.up
create_table :table_points, :force => true do |t|
t.string :data
t.point :geom, :srid => 4326, :with_z => false
end
add_index :table_points, :geom, :spatial=>true
end
def self.down
drop_table :table_points
end
end

SRID=4326はWGS 84 空間参照系

9.開発用DBにマイグレーション
rake db:migrate


10.テスト用fixtureはこんなかんじ。
one:
id: 1
data: MyString
geom: <%= Point.from_x_y(0.0, 0.0, 4326).to_fixture_format %>


11.テスト準備。
rake db:test:clone_structure  # 開発用DBからスキーマを複製
rake db:test:prepare        # テスト用 DB を準備


12.テスト実行。
rake test



■参考
http://georuby.rubyforge.org/spatialadapter-doc/index.html
http://github.com/melriffe/spatial_adapter/tree/master/README
RailsのテストでPostGISのGeometry型を扱いたい。
-> http://marnica.blog66.fc2.com/blog-entry-74.html