Rails doesn't reload routes.rb in development

694 views
Skip to first unread message

Darius Pakusas

unread,
Feb 13, 2015, 4:09:40 AM2/13/15
to rubyonra...@googlegroups.com
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

Colin Law

unread,
Feb 13, 2015, 4:26:23 AM2/13/15
to rubyonra...@googlegroups.com
On 13 February 2015 at 09:09, Darius Pakusas <dar...@pakusas.lt> 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.

>
> 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"]

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

Colin

Darius Pakusas

unread,
Feb 13, 2015, 4:57:42 AM2/13/15
to rubyonra...@googlegroups.com


On Friday, February 13, 2015 at 11:26:23 AM UTC+2, Colin Law wrote:
On 13 February 2015 at 09:09, Darius Pakusas <dar...@pakusas.lt> 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.
 
Even in development? On the web I find older resources saying routes.rb also is reloaded if file is changed.
 
>
> 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"]

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

Colin Law

unread,
Feb 13, 2015, 5:17:18 AM2/13/15
to rubyonra...@googlegroups.com
On 13 February 2015 at 09:57, Darius Pakusas <dar...@pakusas.lt> wrote:
>
>
> On Friday, February 13, 2015 at 11:26:23 AM UTC+2, Colin Law wrote:
>>
>> On 13 February 2015 at 09:09, Darius Pakusas <dar...@pakusas.lt> 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.
>
>
> 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

Darius Pakusas

unread,
Feb 13, 2015, 6:17:03 AM2/13/15
to rubyonra...@googlegroups.com

Colin Law

unread,
Feb 13, 2015, 6:36:47 AM2/13/15
to rubyonra...@googlegroups.com
On 13 February 2015 at 11:17, Darius Pakusas <dar...@pakusas.lt> 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
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/33b3ac7e-2e76-4052-b70b-f58a79e1fc25%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

tamouse pontiki

unread,
Feb 13, 2015, 10:44:32 PM2/13/15
to rubyonra...@googlegroups.com
Sometimes spring is running, preventing the server from picking up changes.

Reply all
Reply to author
Forward
0 new messages