2009年4月29日水曜日

sakuraにrails まとめ?-1-

sakuraインターネットにrailsアプリを入れる。。。
いろいろやってごっちゃになったのでまとめ?
MySQL用
  1. %rails todo -d mysql  
  2.       create    
  3.       create  app/controllers  
  4.       create  app/helpers  
  5.       create  app/models  
  6.       create  app/views/layouts  
  7.       create  config/environments  
  8.       create  config/initializers  
  9.       create  config/locales  
  10.       create  db  
  11.       create  doc  
  12.       create  lib  
  13.       create  lib/tasks  
  14.       create  log  
  15.       create  public/images  
  16.       create  public/javascripts  
  17.       create  public/stylesheets  
  18.       create  script/performance  
  19.       create  test/fixtures  
  20.       create  test/functional  
  21.       create  test/integration  
  22.       create  test/performance  
  23.       create  test/unit  
  24.       create  vendor  
  25.       create  vendor/plugins  
  26.       create  tmp/sessions  
  27.       create  tmp/sockets  
  28.       create  tmp/cache  
  29.       create  tmp/pids  
  30.       create  Rakefile  
  31.       create  README  
  32.       create  app/controllers/application_controller.rb  
  33.       create  app/helpers/application_helper.rb  
  34.       create  config/database.yml  
  35.       create  config/routes.rb  
  36.       create  config/locales/en.yml  
  37.       create  config/initializers/backtrace_silencers.rb  
  38.       create  config/initializers/inflections.rb  
  39.       create  config/initializers/mime_types.rb  
  40.       create  config/initializers/new_rails_defaults.rb  
  41.       create  config/initializers/session_store.rb  
  42.       create  config/environment.rb  
  43.       create  config/boot.rb  
  44.       create  config/environments/production.rb  
  45.       create  config/environments/development.rb  
  46.       create  config/environments/test.rb  
  47.       create  script/about  
  48.       create  script/console  
  49.       create  script/dbconsole  
  50.       create  script/destroy  
  51.       create  script/generate  
  52.       create  script/runner  
  53.       create  script/server  
  54.       create  script/plugin  
  55.       create  script/performance/benchmarker  
  56.       create  script/performance/profiler  
  57.       create  test/test_helper.rb  
  58.       create  test/performance/browsing_test.rb  
  59.       create  public/404.html  
  60.       create  public/422.html  
  61.       create  public/500.html  
  62.       create  public/index.html  
  63.       create  public/favicon.ico  
  64.       create  public/robots.txt  
  65.       create  public/images/rails.png  
  66.       create  public/javascripts/prototype.js  
  67.       create  public/javascripts/effects.js  
  68.       create  public/javascripts/dragdrop.js  
  69.       create  public/javascripts/controls.js  
  70.       create  public/javascripts/application.js  
  71.       create  doc/README_FOR_APP  
  72.       create  log/server.log  
  73.       create  log/production.log  
  74.       create  log/development.log  
  75.       create  log/test.log  

できたら、config/database.ymlを編集。
  1. development:  
  2.   adapter: mysql  
  3.   encoding: utf8  
  4.   reconnect: false  
  5.   database: todo_development  
  6.   pool: 5  
  7.   username: root  
  8.   password:  
  9.   host: localhost  

↓↓変更↓↓
  1. development:  
  2.   adapter: mysql  
  3.   encoding: utf8  
  4.   reconnect: false  
  5.   database: DB名  
  6.   pool: 5  
  7.   username: ユーザ名  
  8.   password: パスワード  
  9.   host: mysqlXX.sakura.ne.jp  

public/.htaccessを作る。
  1. # General Apache options  
  2. AddHandler fastcgi-script .fcgi  
  3. AddHandler cgi-script .cgi  
  4. #Options +FollowSymLinks +ExecCGI  
  5.   
  6. ewriteEngine On  
  7.   
  8. RewriteRule ^$ index.html [QSA]  
  9. RewriteRule ^([^.]+)$ $1.html [QSA]  
  10. RewriteCond %{REQUEST_FILENAME} !-f  
  11. RewriteRule ^(.*)$ dispatch.cgi [QSA,L]  
  12.   
  13. ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"  

次に、logとtmpのパーミッション変更。
  1. %chmod -R o+w log tmp  

config/environment.rbの先頭に以下を追加。
  1. $LOAD_PATH.push("/home/xxxxx/lib/ruby")  
  2. $LOAD_PATH.push("/home/xxxxx/lib")  
  3. ENV['GEM_HOME'] ||= '/home/xxxxx/lib/ruby/gem'  
  4. ENV['RAILS_RELATIVE_URL_ROOT']="/todo"  


で、シンボリックリンクを張る
  1. %ln -s $HOME/rails-apl/todo/public/ $HOME/www/todo  


ここまでやって
Not Found
The requested URL /hello/dispatch.cgi was not found on this server.
と、エラーがでる。。。
未解決中!

↓ランキング参加中!ポチッとお願いします。
ブログランキング・にほんブログ村へ人気ブログランキングへ

sakuraレンタルサーバにRailsをいれる MySQLドライバ

MySQLを使えるように・・・
  1. %gem install mysql  
  2. >Building native extensions.  This could take a while...  
  3. >Successfully installed mysql-2.7  
  4. >1 gem installed  

ん?なんだかあっさり成功?

↓ランキング参加中!ポチッとお願いします。
ブログランキング・にほんブログ村へ人気ブログランキングへ

2009年4月26日日曜日

rails/info/properties was not found on this server.

前回、やっとできたと思ったrailsですが、
About your application’s environment
のリンクをクリックすると
Not Found
The requested URL /hello/rails/info/properties was not found on this server.

なんてエラーが。。。

設定がまだ足りなかったみたいです。
という事で設定を追加!

configの中にあるenvironment.rbをviとかで開く。
  1. %cd $HOME/rails-apl/hello/config/  
  2. %vi environment.rb  

で、冒頭に以下を追加。
  1. $LOAD_PATH.push("/home/xxxxx/lib/ruby/site_ruby/1.8")  
  2. $LOAD_PATH.push("/home/xxxxx/lib/ruby")  
  3. ENV['GEM_HOME'] ||= '/home/xxxxx/lib/ruby/gem'  
  4. ENV['RAILS_RELATIVE_URL_ROOT']="/hello"  

さらにpublicの中にある.htaccessをviとかで開く。
。。と思ったら.htaccessがない!
READMEに書かれてるっぽいのでコピーして.htaccessファイルを作成する。
中身は以下のような感じだと思います。
  1. # General Apache options  
  2. AddHandler fastcgi-script .fcgi  
  3. AddHandler cgi-script .cgi  
  4. Options +FollowSymLinks +ExecCGI  
  5. # If you don't want Rails to look in certain directories,  
  6. # use the following rewrite rules so that Apache won't rewrite certain requests  
  7. ## Example:  
  8. #   RewriteCond %{REQUEST_URI} ^/notrails.*  
  9. #   RewriteRule .* - [L]  
  10.   
  11. # Redirect all requests not available on the filesystem to Rails  
  12. # By default the cgi dispatcher is used which is very slow  
  13. ## For better performance replace the dispatcher with the fastcgi one  
  14. ## Example:  
  15. #   RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]  
  16. RewriteEngine On  
  17.   
  18. # If your Rails application is accessed via an Alias directive,  
  19. # then you MUST also set the RewriteBase in this htaccess file.  
  20. ## Example:  
  21. #   Alias /myrailsapp /path/to/myrailsapp/public  
  22. #   RewriteBase /myrailsapp  
  23. RewriteRule ^$ index.html [QSA]  
  24. RewriteRule ^([^.]+)$ $1.html [QSA]  
  25. RewriteCond %{REQUEST_FILENAME} !-f  
  26. RewriteRule ^(.*)$ dispatch.cgi [QSA,L]  
  27.   
  28. # In case Rails experiences terminal errors  
  29. # Instead of displaying this message you can supply a file here which will be rendered instead  
  30. ## Example:  
  31. #   ErrorDocument 500 /500.html  
  32. ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"  

で、最初の2行目から4行目までをコメントアウト
  1. #AddHandler fastcgi-script .fcgi  
  2. #AddHandler cgi-script .cgi  
  3. #Options +FollowSymLinks +ExecCGI  

すると今度は
Not Found
The requested URL /hello/dispatch.cgi was not found on this server.

。。。なんだこりゃ。。。まだ設定不足?
これはまた次回ってことで!

↓ランキング参加中!ポチッとお願いします。
ブログランキング・にほんブログ村へ人気ブログランキングへ

undefined method `camelize' for "app":String

前回、タイトルにあるようなエラーでrailsのテンプレートが作成できなかった。
いろいろ調べてるとiconv-rubyのインストールが必要?みたいだ。。。
ということでやってみる!
  1. %cd local/src/ruby-1.8.7-p160/ext/iconv/  
  2. %ruby extconf.rb --with-iconv-dir=/usr/local  
  3. %make  
  4. %make install  

これでいいのかな?

railsアプリを置く予定のディレクトリに移動して
  1. %cd $HOME/rails-apl/  
  2. %rails hello  

とやったら、無事helloができました。
次は少々設定。。。
logとtmpディレクトリのパーミッションを変更
  1. %cd $HOME/rails-apl/hello/  
  2. %chmod -R o+w log tmp  

そしたら、webで見れるようにシンボリックリンクを張るといいみたいです。
  1. %ln -s $HOME/rails-apl/hello/public/ $HOME/www/hello  

こんな感じかな?
これでhttp://xxxxx.sakura.ne.jp/hello/にアクセスしたら












となってればOKですね♪

↓ランキング参加中!ポチッとお願いします。
ブログランキング・にほんブログ村へ人気ブログランキングへ

2009年4月18日土曜日

ruby on rails を試してみる。

sakuraレンタルサーバにruby、gems、railsのインストールが完了したので、
試しに動かしてみる。

<状況>
・ruby 1.9.1p0
・gems 1.3.2
・rails 2.3.2

まずはRailsアプリディレクトりを作成。
www以外の場所に作成。
  1. % cd $HOME  
  2. % mkdir rails-apl  
  3. % cd rails-apl  
  4. % rails test  

あれ?エラーになってしまった。。。

  1. <internal:gem_prelude>:234:in `push_gem_version_on_load_path': Could not find RubyGem activesupport (>= 0) (Gem::LoadError)  
  2. </internal:gem_prelude>  


なんかバージョンのせいみたいな事をどこかに書かれてた!
で、Rubyを1.8.7に変更したら今度は
  1. %rails hello  
  2. >undefined method `camelize' for "app":String  

と、なってしまった!

↓ランキング参加中!ポチッとお願いします。
ブログランキング・にほんブログ村へ人気ブログランキングへ

2009年4月17日金曜日

Twitter はじめました

ふと思いついた事のメモをしようとTwitterやることにしました。

まずは挨拶から。。
そして、ぼやきとか思いつきアイディアとか、
気になるツールとか気になる広告とか。。

いまいち使い方がわからんけど・・・
ブログパーツもあったので、設置してみた♪

↓ランキング参加中!ポチッとお願いします。
ブログランキング・にほんブログ村へ人気ブログランキングへ

2009年4月5日日曜日

SAStruts リダイレクト

@Executeアノテーションにredirect=trueにするといいみたいです。
またはクエリストリングに付与する方法もあるみたいです。

通常?↓
  1. @Execute(validator = false, redirect = true)  
  2. public String showGoogle() {  
  3.  return "http://www.google.co.jp";  
  4. }  


クエリストリング?↓
  1. @Execute(validator = false)  
  2. public String showGoogle() {  
  3.  return "http://www.google.co.jp?redirect=true";  
  4. }  


↓ランキング参加中!ポチッとお願いします。
ブログランキング・にほんブログ村へ人気ブログランキングへ

AmaterasでStrutsタグエラー

JSP編集中にStrutsタグを使用してると
「"html"に対応するtaglibディレクティブが存在しないかTLDファイルが見つかりません。」
とのエラーが表示される。
しかし、動作上は問題なく動いている。。。
Amaterasのバグ?。。。補完機能が使えないだけか。。。不便。。

-ネットで調査-

なんかプロジェクトの設定で回避できるみたい♪
プロジェクト→プロパティー→Amateras
ルートに「/src/main/webapp」とWEB-INFのあるディレクトリを指定する。
で、OKなはず!

。。。なんかうまくいかない。。。
ぁ、Eclipseを再起動したらできた◎

↓ランキング参加中!ポチッとお願いします。
ブログランキング・にほんブログ村へ人気ブログランキングへ

2009年4月4日土曜日

新規Doltengプロジェクト作成時にエラー

Eclipseを使用してSAStrusプロジェクトを作成しようと
新規→プロジェクト→Dolteng→Doltengプロジェクト
にて、プロジェクト名、ルートパッケージ名等を入力した際、
Maven Local Repository Directory is not found:
と、メッセージが出てプロジェクト作成できない。。。



















そんな時は
ウィンドウズ→設定→Dolteng
にて、「オンラインからリソースをダウンロード」のチェックを外す。

















これでSAStrutsプロジェクトが作成できるはず♪

↓ランキング参加中!ポチッとお願いします。
ブログランキング・にほんブログ村へ人気ブログランキングへ