1

I'm building a Rails plugin that currently provides controllers and models to an app. However I get a missing template error when it comes to views. I have the following:

%w{ models controllers views }.each do |dir|
  path = File.join(File.dirname(__FILE__), 'app', dir)
  $LOAD_PATH << path
  ActiveSupport::Dependencies.autoload_paths << path
  ActiveSupport::Dependencies.autoload_once_paths.delete(path)
end

The controllers and models are loaded but not views. The Rails guide says it can be done but doesn't have an example. Is there a way to include them (or a similar alternative)?

Shannon
  • 2,988
  • 10
  • 21

1 Answers1

0

You didn't include the version you're working with ... reason that's important is after rails 4 came out - you're not supposed to be doing plugins anymore ... Gem Vs Plugin Vs Engine in Ruby on Rails.

If you're not supporting a legacy app, would highly recommend going with a 'rails engine', the Devise Gem is one great example...it's a self-encapsulated app, with it's own view files & sounds exactly like what you're trying to do. Additionally, it shows you can even use generators to move your default views/controllers out of the engine & change the basic routing if someone needs to customize your work further.

Community
  • 1
  • 1
Mirv - Matt
  • 553
  • 7
  • 22