環境はMacOSX 10.5.8。
まずあらかじめGrailsの動く環境を整えておきます。現在の最新版、Grails-1.1.1を準備しました。
セットアップはいろいろな人が書いているので省略。
自分のワークディレクトリに移動し、 http://code.google.com/p/gcrnagoya/ からソースコードをSVNで落とします。
$ svn checkout http://gcrnagoya.googlecode.com/svn/trunk/simple simple
simpleフォルダができるので、中の application.properties を確認。
#Do not edit app.grails.* properties, they may change automatically. DO NOT put application configuration in here, it is not the right place!
#Thu May 07 12:43:04 JST 2009
app.version=0.1
app.servlet.version=2.4
app.grails.version=1.0.5
app.name=simple
Grailsの作成バージョンが1.0.5なので、grails upgrade(※あんまり信用されてないコマンドなので注意)を実行します。
$ grails upgrade
もう一度 application.properties の中を確認すると、
#utf-8
#Sat Aug 29 18:13:30 JST 2009
app.version=0.1
app.servlet.version=2.4
app.grails.version=1.1.1
plugins.hibernate=1.1.1
app.name=simple
次に grails-upp/conf/ に BuildConfig.groovy を作成し、以下を記述します。
grails.project.plugins.dir="work_tmp/plugins"
grails.project.work.dir="work_tmp/work"
これを書いておくと、 デフォルトでは ~/.grails/1.1.1/plugins にインストールされるプラグインを、アプリケーションの work_tmp/plugins/ 以下にインストールしてくれます。
plugins フォルダにプラグインのzip(grails-acegi-0.3.zip,grails-feeds-1.4.zip)が入っているのですが、これをさっくり無視して本家リポジトリからプラグインをインストールします。
$ grails install-plugin acegi
$ grails install-plugin feeds
application.properties を確認すると、
#utf-8
#Sat Aug 29 18:25:48 JST 2009
plugins.feeds=1.4
app.version=0.1
plugins.acegi=0.5.2
app.servlet.version=2.4
app.grails.version=1.1.1
plugins.hibernate=1.1.1
app.name=simple
となりました。
アプリケーションにwork_tmpフォルダができて、中の plugins の中に acegi-0.5.2 と feeds-1.4 がインストールされます。
アプリケーション直下の plugins フォルダは捨ててしまいます。
これで、grails-appしてみます。
$ grails run-app
Welcome to Grails 1.1.1 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /opt/grails-1.1.1
----- 省略 -----
create default role & user
Server running. Browse to http://localhost:8080/simple
ブラウザから http://localhost:8080/simple を開くと、

わー。
初期状態だとユーザがひとつもないので、ユーザを新規作成します。

登録すると自動でログインします。
トップページがないので、まずトップページを作成します。


初期状態だと、タイトルに「top」とつけたページがトップページになるようです。それを「index」に変更したいので、
grails-upp/conf/config.groovy の 76行目
simple.contents.toppage="top"を
simple.contents.toppage="index"に変更します。
リロードすると index がトップになるように反映されています。

とてもシンプル。
8/30追記:
ところで、起動コンソールを見ていると、いくつか起動時にエラーが出ています。
2009-08-30 14:07:55,428
[main] ERROR commons.DefaultGrailsControllerClass -
The allowedMethods property in RoleController should be declared static.
The non static version is supported for now but has been
deprecated and may not work in future versions of Grails.
----- 省略 -----
これを解消するために、grails-app/controllers/
- RegisterController.groovy
- RequestmapController.groovy
- RoleController.groovy
- UserController.groovy
def allowedMethodsとなっている部分を
static allowedMethodsに修正します。
参考ページ:Grails-1.0.*からGrails-1.1への〜 Pt.1 - leftovers...

2 コメント:
いつのまにかGrailsどっぷりですね!
2年目にしてようやくですよー
コメントを投稿