« Return to Thread: Google App Engine Rails Template

Re: Google App Engine Rails Template

by Ryan Brown-4 :: Rate this Message:

Reply to Author | View in Thread

First of all, I really recommend doing your development under the App
Engine dev_appserver. There's plenty of ways to get automatic
reloading. It sounds like this template already sets up symbolic links
for you. In that case you probably just need to edit you web.xml to
set your environment to development instead of production. Just make
sure you set it back before deploying to production.

Second, if you want to set up a test datastore I suggest using the
AppEngine::Testing module from the appengine-apis gem. The easiest way
is to require 'appengine-apis/local_boot'.  This will add the
necessary jars to your class path and read  your appengine-web.xml to
set you up with the same on disk datastore that dev_appserver uses.
It does nothing if things were already configured by dev_appserver or
the prod servers, so it should be fine to just add this to your
environment.rb
You can also call AppEngine::Testing::install_test_datastore if you
want an in-memory datastore for unittests.

-- Ryan Brown



On Tue, Jun 16, 2009 at 12:38 PM, Carson Welsh<carsonwelsh@...> wrote:

> Ignore my last message. Sorry.
>
> I had a whitespace mistake on this line:
>
> ApiProxy.delegate = Class.new(ApiProxyLocalImpl).new java.io.File.new('.')
>
> But I'm still curious why those two lines are commented out in
> setup_datastore and teardown_datastore.
>
>
>
> On Tue, Jun 16, 2009 at 3:31 PM, Carson Welsh<carsonwelsh@...> wrote:
>> Thanks. Cleared that hurdle.
>>
>> Now the error I'm getting is inside the code you added to
>> application_controller.rb:
>>
>> "wrong # of arguments for constructor" in
>> application_controller.rb:32:in `setup_datastore'
>>
>> Looks like the problem is in the second line of the setup_datastore method.
>>
>> Did you do any customization here?
>>
>> Also, probably not related to this error I'm getting but, it looks
>> like maybe you commented out those two lines beginning with
>> "ApiProxy"? If so, was there a reason?
>>
>>    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
>>
>>
>>
>> On Tue, Jun 16, 2009 at 2:45 PM, Christian Seiler <chr.seiler@...> wrote:
>>>
>>> Forgot about two other jar files:
>>>
>>> appengine-api-stubs-1.2.1.jar
>>> appengine-local-runtime-1.2.1.jar
>>>
>>> But you shouldn't put them into the lib folder, because I think Warbler
>>> would pick them up and include them in the war file. You don't want
>>> these libs on AppEngine.
>>>
>>>
>>> Carson Welsh wrote:
>>> >
>>> > Hi Christian,
>>> >
>>> > I wonder if you have any idea what might be going wrong here. I
>>> > downloaded the Nick Sieger template and added your addition to the
>>> > application_controller.rb, added the appengine-api-1.0-sdk-1.2.1.jar
>>> > to the lib folder and require it in config/development.rb. But I get
>>> > the following error after I start the application:
>>> >
>>> > NameError in SnoopController#index
>>> >
>>> > cannot load Java class
>>> > com.google.appengine.api.datastore.dev.LocalDatastoreService
>>> >
>>> > RAILS_ROOT: C:/wsp/siegerails/examples/rails
>>> >
>>> > Application Trace | Framework Trace | Full Trace
>>> > C:/jr/lib/ruby/site_ruby/1.8/builtin/javasupport/core_ext/object.rb:87:in
>>> > `get_proxy_or_package_under_package'
>>> > C:/jr/lib/ruby/site_ruby/1.8/builtin/javasupport/java.rb:51:in
>>> > `method_missing'
>>> > C:/wsp/siegerails/examples/rails/app/controllers/application_controller.rb:20
>>> > C:/wsp/siegerails/examples/rails/app/controllers/application_controller.rb:380:in
>>> > `load'
>>> > C:/wsp/siegerails/examples/rails/app/controllers/snoop_controller.rb:1
>>> > C:/wsp/siegerails/examples/rails/app/controllers/snoop_controller.rb:380:in
>>> > `load'
>>> >
>>> >
>>> >
>>> > On Tue, Jun 16, 2009 at 5:12 AM, Christian Seiler
>>> > <chr.seiler@... <mailto:chr.seiler@...>> wrote:
>>> >
>>> >     I haven't played with it lately so I need to recall..
>>> >
>>> >     Well, first of all my dev environment is not a real AppEngine setup,
>>> >     it's plain JRuby/Rails plus Datastore. That's all I have used so
>>> >     far (no
>>> >     memcache or mailer). One thing you need to do is require the
>>> >     appengine-api-1.0-sdk-1.2.1.jar to make the AppEngine stuff available.
>>> >     I've put the jar in the lib folder and require it in
>>> >     config/development.rb.
>>> >
>>> >     I think that's all. By the way, I used this example as project
>>> >     template:
>>> >     http://github.com/nicksieger/jruby-rack/tree/bb907c03c48eb999e7d099068245b91eeda545bf/examples/rails
>>> >
>>> >     I hope this helps!
>>> >
>>> >     Carson Welsh wrote:
>>> >     >
>>> >     > Hi Christian
>>> >     >
>>> >     > Thanks for the code sample.
>>> >     >
>>> >     > I am very eager to use a standard Ruby development environment
>>> >     for App
>>> >     > Engine without restarts as you have described.
>>> >     >
>>> >     > I have spent several hours trying to use your code sample to
>>> >     configure
>>> >     > a Rails project with GAE but so far have been unsuccessful.
>>> >     >
>>> >     > Have you made any other significant changes to your Rails app
>>> >     besides
>>> >     > what you mentioned?
>>> >     >
>>> >     > Thanks,
>>> >     > Carson
>>> >     >
>>> >     >
>>> >     >
>>> >     >
>>> >     >
>>> >     >     From: *Christian Seiler* <chr.seiler@...
>>> >     <mailto:chr.seiler@...>
>>> >     >     <mailto:chr.seiler@... <mailto:chr.seiler@...>>>
>>> >     >     Date: Mon, Jun 15, 2009 at 5:37 AM
>>> >     >     To: user@... <mailto:user@...>
>>> >     <mailto:user@... <mailto:user@...>>
>>> >     >
>>> >     >
>>> >     >     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
>>> >     >
>>> >     ---------------------------------------------------------------------
>>> >     >     To unsubscribe from this list, please visit:
>>> >     >
>>> >     >        http://xircles.codehaus.org/manage_email
>>> >     >
>>> >     >
>>> >     >
>>> >     >
>>> >     >
>>> >
>>> >
>>> >     ---------------------------------------------------------------------
>>> >     To unsubscribe from this list, please visit:
>>> >
>>> >        http://xircles.codehaus.org/manage_email
>>> >
>>> >
>>> >
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Google App Engine Rails Template