2009年4月29日水曜日

sakuraにrails まとめ?-1-

sakuraインターネットにrailsアプリを入れる。。。
いろいろやってごっちゃになったのでまとめ?
MySQL用

%rails todo -d mysql
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create config/locales
create db
create doc
create lib
create lib/tasks
create log
create public/images
create public/javascripts
create public/stylesheets
create script/performance
create test/fixtures
create test/functional
create test/integration
create test/performance
create test/unit
create vendor
create vendor/plugins
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create Rakefile
create README
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create config/database.yml
create config/routes.rb
create config/locales/en.yml
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/new_rails_defaults.rb
create config/initializers/session_store.rb
create config/environment.rb
create config/boot.rb
create config/environments/production.rb
create config/environments/development.rb
create config/environments/test.rb
create script/about
create script/console
create script/dbconsole
create script/destroy
create script/generate
create script/runner
create script/server
create script/plugin
create script/performance/benchmarker
create script/performance/profiler
create test/test_helper.rb
create test/performance/browsing_test.rb
create public/404.html
create public/422.html
create public/500.html
create public/index.html
create public/favicon.ico
create public/robots.txt
create public/images/rails.png
create public/javascripts/prototype.js
create public/javascripts/effects.js
create public/javascripts/dragdrop.js
create public/javascripts/controls.js
create public/javascripts/application.js
create doc/README_FOR_APP
create log/server.log
create log/production.log
create log/development.log
create log/test.log

できたら、config/database.ymlを編集。

development:
adapter: mysql
encoding: utf8
reconnect: false
database: todo_development
pool: 5
username: root
password:
host: localhost

↓↓変更↓↓

development:
adapter: mysql
encoding: utf8
reconnect: false
database: DB名
pool: 5
username: ユーザ名
password: パスワード
host: mysqlXX.sakura.ne.jp

public/.htaccessを作る。

# General Apache options
AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
#Options +FollowSymLinks +ExecCGI

ewriteEngine On

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

ErrorDocument 500 "

Application error

Rails application failed to start properly"

次に、logとtmpのパーミッション変更。

%chmod -R o+w log tmp

config/environment.rbの先頭に以下を追加。

$LOAD_PATH.push("/home/xxxxx/lib/ruby")
$LOAD_PATH.push("/home/xxxxx/lib")
ENV['GEM_HOME'] ||= '/home/xxxxx/lib/ruby/gem'
ENV['RAILS_RELATIVE_URL_ROOT']="/todo"


で、シンボリックリンクを張る

%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を使えるように・・・

%gem install mysql
>Building native extensions. This could take a while...
>Successfully installed mysql-2.7
>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とかで開く。

%cd $HOME/rails-apl/hello/config/
%vi environment.rb

で、冒頭に以下を追加。

$LOAD_PATH.push("/home/xxxxx/lib/ruby/site_ruby/1.8")
$LOAD_PATH.push("/home/xxxxx/lib/ruby")
ENV['GEM_HOME'] ||= '/home/xxxxx/lib/ruby/gem'
ENV['RAILS_RELATIVE_URL_ROOT']="/hello"

さらにpublicの中にある.htaccessをviとかで開く。
。。と思ったら.htaccessがない!
READMEに書かれてるっぽいのでコピーして.htaccessファイルを作成する。
中身は以下のような感じだと思います。

# General Apache options
AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI
# If you don't want Rails to look in certain directories,
# use the following rewrite rules so that Apache won't rewrite certain requests
## Example:
# RewriteCond %{REQUEST_URI} ^/notrails.*
# RewriteRule .* - [L]

# Redirect all requests not available on the filesystem to Rails
# By default the cgi dispatcher is used which is very slow
## For better performance replace the dispatcher with the fastcgi one
## Example:
# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
RewriteEngine On

# If your Rails application is accessed via an Alias directive,
# then you MUST also set the RewriteBase in this htaccess file.
## Example:
# Alias /myrailsapp /path/to/myrailsapp/public
# RewriteBase /myrailsapp
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

# In case Rails experiences terminal errors
# Instead of displaying this message you can supply a file here which will be rendered instead
## Example:
# ErrorDocument 500 /500.html
ErrorDocument 500 "

Application error

Rails application failed to start properly"

で、最初の2行目から4行目までをコメントアウト

#AddHandler fastcgi-script .fcgi
#AddHandler cgi-script .cgi
#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のインストールが必要?みたいだ。。。
ということでやってみる!

%cd local/src/ruby-1.8.7-p160/ext/iconv/
%ruby extconf.rb --with-iconv-dir=/usr/local
%make
%make install

これでいいのかな?

railsアプリを置く予定のディレクトリに移動して

%cd $HOME/rails-apl/
%rails hello

とやったら、無事helloができました。
次は少々設定。。。
logとtmpディレクトリのパーミッションを変更

%cd $HOME/rails-apl/hello/
%chmod -R o+w log tmp

そしたら、webで見れるようにシンボリックリンクを張るといいみたいです。

%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以外の場所に作成。

% cd $HOME
% mkdir rails-apl
% cd rails-apl
% rails test

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


:234:in `push_gem_version_on_load_path': Could not find RubyGem activesupport (>= 0) (Gem::LoadError)


なんかバージョンのせいみたいな事をどこかに書かれてた!
で、Rubyを1.8.7に変更したら今度は

%rails hello
>undefined method `camelize' for "app":String

と、なってしまった!

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

2009年4月17日金曜日

Twitter はじめました

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

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

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

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

2009年4月5日日曜日

SAStruts リダイレクト

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

通常?↓

@Execute(validator = false, redirect = true)
public String showGoogle() {
return "http://www.google.co.jp";
}


クエリストリング?↓

@Execute(validator = false)
public String showGoogle() {
return "http://www.google.co.jp?redirect=true";
}


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

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プロジェクトが作成できるはず♪

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