Skip to content
This repository has been archived by the owner on May 16, 2021. It is now read-only.

Reloader doesn't work when sinatra is mounted into Rails application. #29

Closed
lexer opened this issue Jan 5, 2012 · 10 comments
Closed

Comments

@lexer
Copy link

lexer commented Jan 5, 2012

Reloader doesn't work when sinatra is mounted into Rails application.

App is mounted this way: mount Api2.new, :at => "/api2"

require 'sinatra/base'
require 'sinatra/reloader'

class Api2 < Sinatra::Base

  configure :development do
    register Sinatra::Reloader
  end

  configure :production do

  end

  get '/hello' do
    "hello 2"
  end
end

Changes will cause "Routing Error"

@rkh
Copy link
Member

rkh commented Jan 5, 2012

Interesting. Rails comes with a reloader, by the way.

@lexer
Copy link
Author

lexer commented Jan 5, 2012

Rails reloader doesn't reload changes in mounted sinatra app

@rkh
Copy link
Member

rkh commented Jan 5, 2012

That depends on how you configure the reloader and/or where you place your Sinatra applications.

@lexer
Copy link
Author

lexer commented Jan 5, 2012

I haven't performed any configuration in rails. The only thing I've done is mount inside routes.rb. Do you know how can I configure rails to reload sinatra code?

@gnandretta
Copy link
Member

@lexer I did a little research and it seems that reloading doesn't work when both Rails and Sinatra::Reloader try to reload the Sinatra application. I haven't found the reason yet, but for now you can tell Rails to stop reloading your application with:

ActiveSupport::Dependencies.autoload_once_paths << '/path/to/your/sinatra/app'

This works with Rails 3.2, Sinatra 1.3.2 and Sinatra Contrib 1.3.1.

@lexer
Copy link
Author

lexer commented Jan 21, 2012

Thanks, I will try.

@lexer
Copy link
Author

lexer commented Feb 1, 2012

@ohhgabriel may its better to let rails reload sinatra app, but i haven't found how to do it yet.

@rayortigas
Copy link

Might have a workaround:

https://gist.github.com/4490968

Tested with:

rails 3.2.11
sinatra 1.3.3
sinatra-contrib 1.3.2

Regards,
Ray

@justqyx
Copy link

justqyx commented Apr 17, 2013

@ohhgabriel

where to write?

ActiveSupport::Dependencies.autoload_once_paths << '/path/to/your/sinatra/app'

@zzak
Copy link
Member

zzak commented Aug 11, 2013

I would recommend using the host application's reloader, in this case Rails.

There have been several solutions suggested here, so I am closing this ticket.

@zzak zzak closed this as completed Aug 11, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants