2

I have tried to push a simple rails 3.2.3 application with mongo_mapper to cloudfoundry, but I am getting 504 Gateway Time-out. The application ran fine on localhost. I provided additional information below. Please could you provide me assistance to resolve this issue?

To create and push application I typed:

rails new myapp -skip-active-record
scaffold massage content:string --skip-migration --orm mongo_mapper
bundle update
bundle install
bundle package
vmc push myapp --runtime ruby19

Here is the Gemfile:

Source 'http://rubygems.org'
gem  rails', '3.2.3
gem  mongo_mapper
gem  bson_ext  
end

Here is the controller:

class MessagesController < ApplicationController
  def index
   @messages = Message.all
    respond_to do |format|
     format.html # index.html.erb
     format.json { render json: @messages }
    end
  end

 def show
  @message = Message.find(params[:id])
  respond_to do |format|
  format.html # show.html.erb
  format.json { render json: @message }
end
end

def new
@message = Message.new
respond_to do |format|
  format.html # new.html.erb
  format.json { render json: @message }
end
end

def edit
 @message = Message.find(params[:id])
end

def create
@message = Message.new(params[:message])

respond_to do |format|
  if @message.save
    format.html { redirect_to @message, notice: 'Message was successfully created.' }
    format.json { render json: @message, status: :created, location: @message }
  else
    format.html { render action: "new" }
    format.json { render json: @message.errors, status: :unprocessable_entity }
  end
end
end

def update
 @message = Message.find(params[:id])

 respond_to do |format|
  if @message.update_attributes(params[:message])
    format.html { redirect_to @message, notice: 'Message was successfully updated.' }
    format.json { head :no_content }
  else
    format.html { render action: "edit" }
    format.json { render json: @message.errors, status: :unprocessable_entity }
  end
end
end

def destroy
 @message = Message.find(params[:id])
 @message.destroy

respond_to do |format|
  format.html { redirect_to messages_url }
  format.json { head :no_content }
end
end
end

Here is the modle:

class Message
 include MongoMapper::Document
 key :content, String
 end

Here is the index view

<h1>Listing messages</h1>

<table>
 <tr>
  <th>Content</th>
 </tr>

 <% @messages.each do |message| %>
 <tr>
  <td><%= message.content %></td>
  <td><%= link_to 'Show', message %></td>
  <td><%= link_to 'Edit', edit_message_path(message) %></td>
  <td><%= link_to 'Destroy', message, :confirm => 'Are you sure?', method: :delete %></td>
 </tr>
 <% end %>
 </table>
 <br />
 <%= link_to 'New Message', new_message_path %>

Here is config/locales/mongo.yml

    defaults: &defaults
host: 127.0.0.1
port: 27017

development:
<<: *defaults
database: proj815_development

test:
<<: *defaults
database: proj815_test

# set these environment variables on your prod server
production:
host: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-1.8'].first['credentials']['hostname'] rescue 'localhost'%>
port: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-1.8'].first['credentials']['port'] rescue '27017'%>
database: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-1.8'].first['credentials']['db'] rescue 'proj815' %>
username: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-1.8'].first['credentials']['username'] rescue ''%>
password: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-1.8'].first['credentials']['password'] rescue ''%>
4

1 回答 1

2

通常发生这种情况是因为您的应用程序太大而无法上传,如果您可以减小应用程序的大小,应该没问题。

于 2013-01-14T22:06:37.100 回答