Closed polivers closed 9 years ago
Fixed this with an initialiser to reload the controllers:
unless Rails.env.production?
Dir["#{Rails.root}/app/controllers/V*"].each do |sub_directory|
Dir.entries(sub_directory).each do |controller|
require_dependency File.join(sub_directory, controller) if controller=~/\.rb$/
end
ActionDispatch::Reloader.to_prepare do
Dir.entries(sub_directory).each do |controller|
require_dependency File.join(sub_directory, controller) if controller=~/\.rb$/
end
end
end
end
Hey @polivers sorry for the radio silence on this. I recently started working at a company that uses GitHub as a SCM, and for some reason that seems to have broken notifications on my personal repos, so I didn't see this until just now.
As for your issue, what Rails env were you running in where you saw this behavior? By default development should reload code on each request, and you shouldn't have to do anything special. Check your environment file matching the Rails env you were running in to see if config.cache_classes
is set to true.
Hi all! I'm trying Versionist out, with Rails 4.
Given this route: api_version(module: "V1", header: {name: "Accept", value: "application/vnd.mycompany.com; version=1"}, parameter: {name: 'version', value: 1}, defaults: {format: 'json'}) do resource :users end
When I GET /users (with the Accept header set), my controller action is called and I get the desired output:
class V1::UsersController < V1::BaseController def show return render json: {message: 'test'}, status: 200 end end
(returns 'test', with status 200).
If i change this method, so it returns "Hello" as the message value, and some other status code - I still get the same response as the previous method. It would seem as though Rails isn't reloading the controller classes upon each request.
My controller is at app/controllers/v1/users_controller.rb, So that looks right to me(given that the controller is namespaced).
Any ideas why the controllers arent reloading? Thanks