Rails doesn't reload routes.rb in development

Hi,

I’m newbie in Rails. When I change routes.rb file Rails does not reload
it,
means /rails/info/routes shows same old routes and rake routes shows
new.
If I stop rails server and start again, it shows new routes. If I rename
routes.rb files I get an exception routes.rb not found.

If I create new controller, change view and other files in app, I can
see
result in browser immediately, means rails reloads that code.

I’m using docker if it is important, Dockerfile:
FROM ruby:2.2.0

RUN apt-get update && apt-get install -y nodejs --no-install-recommends
&&
rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y mysql-client postgresql-client
sqlite3 --no-install-recommends && rm -rf /var/lib/apt/lists/*

RUN bundle config --global frozen 1

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY Gemfile /usr/src/app/
COPY Gemfile.lock /usr/src/app/

RUN bundle install

EXPOSE 3000
CMD [“rails”, “server”, “-b”, “0.0.0.0”]

Darius

On 13 February 2015 at 09:09, Darius P. [email protected] wrote:

Hi,

I’m newbie in Rails. When I change routes.rb file Rails does not reload it,
means /rails/info/routes shows same old routes and rake routes shows new. If
I stop rails server and start again, it shows new routes. If I rename
routes.rb files I get an exception routes.rb not found.

Yes, that is the way it works. If you change routes.rb you need to
restart the server.

sqlite3 --no-install-recommends && rm -rf /var/lib/apt/lists/*

EXPOSE 3000
CMD [“rails”, “server”, “-b”, “0.0.0.0”]

I don’t understand your point about why it is important in this case.
Please clarify.

Colin

On Friday, February 13, 2015 at 11:26:23 AM UTC+2, Colin L. wrote:

routes.rb files I get an exception routes.rb not found.

Yes, that is the way it works. If you change routes.rb you need to
restart the server.

Even in development? On the web I find older resources saying routes.rb
also is reloaded if file is changed.

rm -rf /var/lib/apt/lists/*

RUN bundle install

EXPOSE 3000
CMD [“rails”, “server”, “-b”, “0.0.0.0”]

I don’t understand your point about why it is important in this case.
Please clarify.

It is really not inportant in this case. My thought was maybe Rails
check
if file was changed does not work because it is in container or
something
like that.

Darius

On 13 February 2015 at 09:57, Darius P. [email protected] wrote:

new. If
I stop rails server and start again, it shows new routes. If I rename
routes.rb files I get an exception routes.rb not found.

Yes, that is the way it works. If you change routes.rb you need to
restart the server.

Even in development? On the web I find older resources saying routes.rb also
is reloaded if file is changed.

Yes, even in development. I do not remember a time when that was not
the case, but my memory may be failing. Have you got a link?

Colin

One of
links
http://stackoverflow.com/questions/17729345/when-do-i-need-to-restart-server-in-rails

On 13 February 2015 at 11:17, Darius P. [email protected] wrote:

One of links

http://stackoverflow.com/questions/17729345/when-do-i-need-to-restart-server-in-rails

Well it turns out I have been spouting garbage. Having just tried it
on a Rails 3.2 and 4.1 app I find that it is not necessary to restart
the server. Very odd, perhaps I am remembering from earlier versions
and had not noticed that it had changed. So thanks Darius for helping
me to find my mistake, it will save me time in the future.

That brings us back though to why you find you need to restart the
server. Are you sure that is the case? Can you provide a concrete
example?

Colin

Sometimes spring is running, preventing the server from picking up
changes.