Posts Tagged ‘Netbeans’

Rails2.0でscaffoldする。

火曜日, 8月 19th, 2008

Rails2.0の壁にぶち当たった昨日の続き。

昨日の「こうすりゃいんじゃね?」まとめ。
——————————————————-
1.db内にデータベース作成する。
2.初期ウィザードで、Mysql指定(これでdatabase.ymlも自動生成)
3.scaffold生成
4.mygrationファイル修正
5.mygrate
6.実行!
——————————————————-

で、今日やってみました。
おおむねOK

忘れないうちに備忘録
——————————————————-
■1.db内にデータベース作成する。

C:\Documents and Settings\Miyai>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.51b-community-nt MySQL Community Edition (GPL)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> drop database rubyweblog_development;
Query OK, 2 rows affected (0.64 sec)

mysql> create database rubyweblog_development;
Query OK, 1 row affected (0.03 sec)

mysql> quit;
Bye

昨日のゴミDBを消して、作っただけ。

■2.初期ウィザードで、Mysql指定(これでdatabase.ymlも自動生成)

NetBeansのプロジェクト作成ウィザードで指定しただけ。(簡単!)

■3.scaffold生成

プロジェクト名を右クリック→「生成」を選択

生成で「scaffold」を選択
名前で「Post title:string」を入力
「了解」ボタンを選択

■4.mygrationファイル修正

修正不要。勝手にgenerateしてくれています。

■5.mygrate

プロジェクト名を右クリック>データベースマイグレーション>現在のバージョン

■6.実行!
失敗!

#良く考えたら、構成とかの編集忘れてました。

■7.構成の編集
<appフォルダ>\config\routes.rb の編集
# map.root :controller => “welcome”

map.root :controller => “posts”

※ここで指定するコントローラ名は複数系。これで軽くはまりました。

■8.デフォルトindexファイル削除
<appフォルダ>\public\index.html を削除

■9.再実行
OK!
——————————————————-

ってか、1.2系より、よっぽど簡単。これは2.0で開発進めるべきか。。。
#自動生成されているソースもわかりやすくなっている。マイグレーションファイル名が、タイムスタンプになってたりとか
#20080818225201_create_posts.rb

Tags: , ,
Posted in Programing | No Comments »

MysqlでDatabase作成

月曜日, 8月 18th, 2008

NetBeansのチュートリアルに沿って、初期プロジェクトを作成したが、Databaseの作成に失敗する。

■なぜか、データベースが作成できない。
C:\Documents and Settings\Miyai>mysqladmin -u root -p create rubyweblog_development
Enter password: ********
mysqladmin: CREATE DATABASE failed; error: ‘Can’t create database ‘rubyweblog_development’; database exists’

C:\Documents and Settings\Miyai>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.51b-community-nt MySQL Community Edition (GPL)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> quit;
Bye

C:\Documents and Settings\Miyai>mysqladmin -u root -p create rubyweblog_development
Enter password: ********
mysqladmin: CREATE DATABASE failed; error: ‘Can’t create database ‘rubyweblog_development’; database exists’

C:\Documents and Settings\Miyai>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.51b-community-nt MySQL Community Edition (GPL)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> quit;
Bye

C:\Documents and Settings\Miyai>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.51b-community-nt MySQL Community Edition (GPL)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> create database rubyweblog_development;
ERROR 1007 (HY000): Can’t create database ‘rubyweblog_development’; database exists

■どうやら、すでに同名のデータベースがある模様。(アンインストールに失敗していた?)
mysql> show databases;
+————————+
| Database |
+————————+
| information_schema |
| depot_development |
| mysql |
| rubyweblog_development |
| test |
+————————+
5 rows in set (0.23 sec)

■不要なデータベースを削除
mysql> drop database depot_development;
Query OK, 2 rows affected (0.33 sec)

mysql> drop database rubyweblog_development;
Query OK, 0 rows affected (0.00 sec)

mysql> drop database test;
Query OK, 0 rows affected (0.02 sec)

mysql> quit;
Bye

■無事作成できた。
C:\Documents and Settings\Miyai>mysqladmin -u root -p create rubyweblog_development
Enter password: ********

C:\Documents and Settings\Miyai>

Tags: ,
Posted in Cocoya.net, Programing | No Comments »

NotePC NetBeans開発環境

月曜日, 8月 18th, 2008

NotePCに Ruby on Rails のNetBeans開発環境を構築する。

■ruby インストール
・One-Click Ruby
ruby186-26.exe

システム環境変数の”path”にrubyのpathを追加
;C:\ruby\bin

■MySQL
mysql-essential-5.0.51b-win32.msi

・default character を utf8 に変更
・Include Bin Directory in Windows PATHにチェックオン

■Rails
gemsでインストール

> gem install rails

c:\ruby>gem install rails
Bulk updating Gem source index for: http://gems.rubyforge.org
Install required dependency rake? [Yn] Y
Install required dependency activesupport? [Yn] Y
Install required dependency activerecord? [Yn] Y
Install required dependency actionpack? [Yn] Y
Install required dependency actionmailer? [Yn] Y
Install required dependency activeresource? [Yn] Y
Successfully installed rails-2.1.0
Successfully installed rake-0.8.1
Successfully installed activesupport-2.1.0
Successfully installed activerecord-2.1.0
Successfully installed actionpack-2.1.0
Successfully installed actionmailer-2.1.0
Successfully installed activeresource-2.1.0
Installing ri documentation for rake-0.8.1…
Installing ri documentation for activesupport-2.1.0…
Installing ri documentation for activerecord-2.1.0…
Installing ri documentation for actionpack-2.1.0…
Installing ri documentation for actionmailer-2.1.0…
Installing ri documentation for activeresource-2.1.0…
Installing RDoc documentation for rake-0.8.1…
Installing RDoc documentation for activesupport-2.1.0…
Installing RDoc documentation for activerecord-2.1.0…
Installing RDoc documentation for actionpack-2.1.0…
Installing RDoc documentation for actionmailer-2.1.0…
Installing RDoc documentation for activeresource-2.1.0…

c:\ruby>gem install rails
Successfully installed rails-2.1.0

#インストール許可を省略する際には”-y”オプション
> gem install rails -y

#1.2系をインストールする場合は以下参照
> gem install rails –version=”1.2.6″ -y

■プログラムインストール結果
C:\Documents and Settings\Miyai>mysql –version
mysql Ver 14.12 Distrib 5.0.51b, for Win32 (ia32)

C:\Documents and Settings\Miyai>rails -v
Rails 2.1.0

C:\Documents and Settings\Miyai>ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]

■NetBeansインストール
JDKが必要
Java SE Downloads

NetBeans 日本語サイト
ja: NetBeans 日本語サイト
netbeans-6.1-ml-ruby-windows.exe
※mlはマルチランゲージの事。日本語版を含みます。

■チュートリアル
Ruby のブログを 10 分で作成 – NetBeans IDE 6.0 チュートリアル

Tags: , , ,
Posted in PC・Server設定 | No Comments »

Get Adobe Flash playerPlugin by wpburn.com wordpress themes