railsアプリケーションの初期設定でハマったこと
さくらサーバーへ、
railsのインストールではまったので、まとめてみる。
ほとんどここに書かれていることと同じ。
http://d.hatena.ne.jp/replication/20090314/1237023281
事前に。ruby hello
で、helloというワークスペースを作成。
ln -s /home/rubytest/Rails_app/hello/public /home/rubytest/www/hello
で、web上の見やすい場所に、シンボリックリンク。
ダミーで出力されたWelcome aboardページの
About your application's environmentを、クリックすると表示される
エラーメッセージに対応する。(うまくいっていればバージョン情報が表示されるはず)
★エラーその1
Not Found
The requested URL /Rails_app/memopad/public/rails/info/properties was not found on this server.
これは.htaccessがないため。public配下に.htaccessを置いたら解消。
★エラーその2
Not Found
/dispatch.cgi not found.
rails 2.3系は
/dispatch.cgiを自動的に作成してくれないそうで、
ページでエラーが起きる。。
結局バージョンダウン
2.2を入れてみる
%gem18 install rails --version 2.2.2
と変わらないので、アンインストール。
%gem18 uninstall rails
Select gem to uninstall:
1. rails-2.2.2
2. rails-2.3.5
3. All versions
> 2
Successfully uninstalled rails-2.3.5
めでたし。
★エラーその3.
Application error
Rails application failed to start properly"
/config/environment.rbを編集し、先頭に以下を追加する。
$LOAD_PATH.push("/home/****/lib/ruby")
$LOAD_PATH.push("/home/****/lib")
ENV['GEM_HOME'] ||= '/home/****/lib/ruby/gem'
★エラーその4.
Routing Error
No route matches "/hello/rails/info/properties" with {:method=>:get}
config/environment.rbを編集し、先頭に以下を追加する。
ENV['RAILS_RELATIVE_URL_ROOT']="/hello"
★エラーその5.
Can't initialize character set utf8 (path: /usr/local/share/mysql/charsets/)
config/database.ymlを編集する。
データベースの設定は config/database.yml
development:
adapter: mysql
database: rubytest
host: mysql218.db.sakura.ne.jp
username: rubytest
password: *****
encoding: utf8
test:
adapter: mysql
database: rubytest
host: mysql218.db.sakura.ne.jp
username: rubytest
password: *****
encoding: utf8
production:
adapter: mysql
database: rubytest
host: mysql218.db.sakura.ne.jp
username: rubytest
password: *****
encoding: utf8
※1ちなみに:コロンの後にスペースいれないと
database is not configured とおこられる
★6.できたー!
Ruby version 1.8.7 (i386-freebsd7)
RubyGems version 1.3.5
Rails version 2.2.2
Active Record version 2.2.2
Action Pack version 2.2.2
Active Resource version 2.2.2
Action Mailer version 2.2.2
Active Support version 2.2.2
Application root /home/rubytest/Rails_app/hello
Environment development
Database adapter mysql
Database schema version 20100315081912