Rails ユーティリティスクリプトを使ってアプリケーションを作成する


スポンサーリンク

1.コマンドプロンプト

1.コマンドプロンプトを開いて、アプリケーションを作りたいディレクトリに移動する。
2.そこで「rails new アプリケーション名」と入力し、Enterを押す。

rails new myapp

2.Aptana Studio 3

[File][New]から[Rails Project]サブメニューを選ぶ。
[Name:]に任意のアプリケーション名を入力する。
[Finish]を押せばアプリケーションが作成される。

3.Gemfileの修正

・テスト用サーバでアプリケーションを実行するための修正
できたプロジェクトに、Gemfileというものがあるので、それを開く。
以下のような記述があるので、それを修正する。

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

上の記述を・・・

# Use sqlite3 as the database for Active Record
group :development, :test do
	gem 'sqlite3'
end

のように変更する。

3.Herokuにデプロイする場合

Gemfileに以下の記述を追加する。

group :production do
	gem 'pg'
end

次に、\myapp\config\environmentsにある、production.rbを修正。
以下の記述を・・・

  # Do not fallback to assets pipeline if a precompiled asset is missed.
  config.assets.compile = false

trueに変更する。

  # Do not fallback to assets pipeline if a precompiled asset is missed.
  config.assets.compile = true

4.Railsアプリを起動

コマンドプロンプトで作成した場合は、アプリケーションフォルダに移動して、

>rails server

を実行。
localhost:3000にアクセスすると、アプリケーションのWelcome画面が見える。

Aptana Studio 3で実行する場合は、App Explorerの上部にある歯車のアイコンをクリックして、[Run Server]でOK。
それでもなぜかサーバが起動しない場合は、Aptanaの下の方にある「アプリケーション名」が書いてあるタブがあるので、そこで
rails server
と実行すれば起動します。


HerokuではじめるRailsプログラミング入門

HerokuではじめるRailsプログラミング入門