My workaround in development mode so far: Simply using Webrick as usual
plus setting up the datastore in the controller (application_controller.rb).
if Rails.env=='development'
before_filter :setup_datastore
after_filter :teardown_datastore
end
protected
if Rails.env=='development'
import com.google.apphosting.api.ApiProxy
import com.google.appengine.api.datastore.dev.LocalDatastoreService
import com.google.appengine.tools.development.ApiProxyLocalImpl
class DevEnvironment
include ApiProxy::Environment
def app_id
'Dev Environment'
end
end
def setup_datastore
ApiProxy.environment_for_current_thread = DevEnvironment.new
ApiProxy.delegate = Class.new(ApiProxyLocalImpl).new
java.io.File.new('.')
#ApiProxy.delegate.set_property
LocalDatastoreService::NO_STORAGE_PROPERTY, 'true'
end
def teardown_datastore
#ApiProxy.delegate.get_service('datastore_v3').clear_profiles
ApiProxy.delegate = nil
ApiProxy.environment_for_current_thread = nil
end
end
Josh Moore wrote:
> Hi Chris,
>
> I think that it is possible to develop ruby apps without the need to
> restart
> (
http://dev.massivebraingames.com/past/2009/4/15/writing_sinatra_apps_for_google/).
> I will be honest I have not looked into this much. However, I think
> the problem with rails is that development mode seems to be
> incompatible with App Engine (I think it has something to do with the
> rails app trying to access the file system). I think if rails can be
> configured to not cache the app files it might work like it does for
> sinatra. I am looking into that now, if you have any insites please
> let me know.
>
> About your last question I have personally not had any experience with
> converting an existing rails app to work with App Engine. So far I
> have worked completely with building new onces.
>
> Josh
>
> On Sun, Jun 14, 2009 at 5:05 AM, Chris Collins <
xoptop@...
> <mailto:
xoptop@...>> wrote:
>
> Hi Josh.
>
> This is a helpful tool for creating a skeleton app. It starts from
> the opposite end of the process than I have been using - creating
> my Rails app and then warbling it and making those tweaks listed
> in your script. But with your script it seems the idea is to
> create the app elsewhere perhaps and then copy the Rails code into
> the app directory once the skeleton has been created with your script.
>
> The biggest problem, which you alluded to in your blog post, still
> seems to be the need to restart the dev server between code
> changes. I believe this has to do with the fact that the Jetty
> server, which normally allows hot deploy for native Java projects,
> does not allow hot deploy when a scripting language like Ruby,
> Groovy or Python is running on top of Java. A potential solution
> to this is to use jetty-rails. As of yet I have not figured
> whether it is possible to get it to work with an App Engine Rails
> project:
>
http://fabiokung.com/2008/05/14/jetty-rails-gem-simple-jruby-on-rails-development-with-servlet-containers/>
> The other adjustment with Rails development on App Engine has to
> do with the ORM but is still related to the hot deploy problem
> with Jetty. Datamapper and Ola Bini's Bumble seem to be the best
> solutions at the moment. But because of the need to restart the
> dev server between code changes, it seems to be more efficient to
> develop a Rails app first outside of the Eclipse/App Engine IDE
> using a real database and ORM and then later modify the app to
> work with Datamapper/Bumble. At least that's the approach I have
> decided to take at the moment. The Eclipse/App Engine environment
> slows me down too much to allow my development to proceed at a
> productive pace. I would be curious whether you have discovered
> any useful tips for the process of converting a regular app from
> ActiveRecord+Sqlite/Mysql to Datamapper/Bumble+Google Datastore.
>
> Regards,
> Chris
>
>
> On Sat, Jun 13, 2009 at 6:42 AM, Josh Moore <
joshsmoore@...
> <mailto:
joshsmoore@...>> wrote:
>
> Hi,
>
> I just finished posting a rails template that creates an app
> ready to deploy on the Google App Engine. Check out the blog
> post
http://www.codingforrent.com/posts/8001 and the template
> at
http://github.com/joshsmoore/gaej_rails_template/tree/master.
> It is still a bit of work in progress. But, it should take
> care of the basics of getting a Rails app set up for
> deployment on the Google App Engine. Please tell me what you
> think.
>
> Josh
>
>
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email