I have a plugin. I want to include some baseline views for the app code to "just use" -- meaning no need to copy files into /app, and no need to specify a path in the controller. Is that possible? If I *have* to add something to the controller, that''s fine. The more important need is to have files reside in the plugin folder. I''ve googled and played with various blog tips, but nothing is working the way I am wanting. This is not a case of applying skins or themes. I just want a set of default files to be available to the app. The closest thing I found was this post, but it doesn''t work. http://weblog.rubyonrails.org/2007/2/4/new-feature-for-rails-2-0-multiple-controller-view-paths The key piece that confuses me is the line ActionController::Base.view_paths.unshift File.join(directory, ''views'') -- it''s not clear where "directory" is being defined. I tried this with no joy: plugin_folder = "#{File.dirname(__FILE__)}" ActionController::Base.view_paths.unshift File.join(plugin_folder, ''views'') I must be missing something, because the above blog post seems like this should be fairly simple. -- gw -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Greg Willits wrote:> I have a plugin. I want to include some baseline views for the app code > to "just use" -- meaning no need to copy files into /app, and no need to > specify a path in the controller. > > Is that possible? If I *have* to add something to the controller, that''s > fine. The more important need is to have files reside in the plugin > folder.ActiveScaffold does this. You might want to take a look at their implementation. If I remember, view_path is involved. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jul 6, 10:49 pm, Greg Willits <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > I tried this with no joy: > > plugin_folder = "#{File.dirname(__FILE__)}" > ActionController::Base.view_paths.unshift File.join(plugin_folder, > ''views'') >How are you trying to use the views in your apps ? If my memory is correct, setting view_paths means that rails will look in there in addition to app/views and so on. However assuming you''re in foo_controller, just as normally render :partial => ''blah'' means look for app/views/foo/_blah, adding to the view_paths means rails will also look for my_plugin/views/foo/ _blah. Were you expecting it to find my_plugin/views/foo ? I believe these days that if you plugin contains a folder called app, itself containing a folder called views then that will be added to the view paths automatically Fred> I must be missing something, because the above blog post seems like this > should be fairly simple. > > -- gw > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung wrote:> I believe these days that if you plugin contains a folder called app, > itself containing a folder called views then that will be added to the > view paths automaticallyThat worked. I went back and tried the unshift thing too, this time with a path that mirrored /app/views/ and that worked. I''m not even sure now exactly what else I could have been doing before, but the partials were not being loaded. Must have been another factor. At any rate, it works like I want now. Default partials w/in plugin folder being found and rendered, and easily overridable by adding a partial in a parallel /app/views folder. Schweet. thx Fred -- gw -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.