views:

59

answers:

1

I'm getting a missing template error after I try rendering a partial from a plugin. I have included the files with the following:

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

The Models are getting loaded, but as for other things I'm not sure what's going on. The helpers are not getting loaded too because I just copied the contents of the partial from the plugin instead of the render :partial => and then it came up with a helper error.

Question is how to be able to :render :partial => from the views folder in my plugin

+1  A: 

For plugin views you usually just copy them to your app/views directory, or the plugin installer copies for you. Views don't work on the $LOAD_PATH the same way models and controllers.

Chris
Ok. I guess this solution is ok because the developer doesn't have to do anything but a rake that could move them into the applications app not the plugin's app but I would rather just have it working in the plugins app.
Sam
The rails guide to building a plugin shows that models, controllers, and helpers can all be accessed, however it doesn't explain views.
Sam
I did stumble upon another tut which said views will get loaded but it had no examples.
Sam
I'm still using Rails 2.2.2 with Engines as a plugin. Engines does allow you to do what you want with views. Later releases of Rails have Engines integration, so you may want to see how you can harness that. Could be overkill though, which is why I didn't suggest it in the first place.
Chris
Yeah, it is overkill. I will just have the views copied over when the plugin is installed.
Sam