Hi all, I''m creating a plugin that has a controller (WebController < ActionController::Base) inside its lib directory (lib/web_controller.rb) so you can access your mini ''control-panel'' via the web but I''m having big problems rendering partials, images, js, etc because Rails is looking by default to /public/images, /public/javascripts, etc... instead of my plugin''s dir. The ideal situation would be to have all the plugin''s images/js/css/views inside my plugin so it doesn''t ''disturb'' your app''s file structure, but I have no idea how to do that. Any help would be really appreciated. Thanks a lot. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mark, I don''t recall where I saw it, but there is a plugin out there that tweaks some of rails internals so that the plugins internal /public/ javascript and /public/images etc are checked. The idea is that instead of dumping everything into /lib in the plugin, your /app and / public directories are mirrored in the plugin as well! I don''t quite recall where I saw it, maybe on "Plugin A Day" site... I''ll search around and see what I find... Eric On Feb 22, 2:13 pm, Mark <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi all, > > I''m creating a plugin that has a controller (WebController < > ActionController::Base) inside its lib directory (lib/web_controller.rb) > so you can access your mini ''control-panel'' via the web but I''m having > big problems rendering partials, images, js, etc because Rails is > looking by default to /public/images, /public/javascripts, etc... > instead of my plugin''s dir. > > The ideal situation would be to have all the plugin''s > images/js/css/views inside my plugin so it doesn''t ''disturb'' your app''s > file structure, but I have no idea how to do that. > > Any help would be really appreciated. > > Thanks a lot. > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Eric, Thanks a lot for the tip. I found it on "Plugin a Week" and it seems pretty interesting, that may be a good place to start. Mark Eric Pugh wrote:> Mark, > > I don''t recall where I saw it, but there is a plugin out there that > tweaks some of rails internals so that the plugins internal /public/ > javascript and /public/images etc are checked. The idea is that > instead of dumping everything into /lib in the plugin, your /app and / > public directories are mirrored in the plugin as well! > > I don''t quite recall where I saw it, maybe on "Plugin A Day" site... > I''ll search around and see what I find... > > Eric-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I actually realized I need to do the same thing, introduce a controller in as part of a plugin.. Hollar if you find it first! On Feb 22, 2:47 pm, Mark <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Eric, > > Thanks a lot for the tip. I found it on "Plugin a Week" and it seems > pretty interesting, that may be a good place to start. > > Mark > > Eric Pugh wrote: > > Mark, > > > I don''t recall where I saw it, but there is a plugin out there that > > tweaks some of rails internals so that the plugins internal /public/ > > javascript and /public/images etc are checked. The idea is that > > instead of dumping everything into /lib in the plugin, your /app and / > > public directories are mirrored in the plugin as well! > > > I don''t quite recall where I saw it, maybe on "Plugin A Day" site... > > I''ll search around and see what I find... > > > Eric > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I found it here http://wiki.pluginaweek.org/Appable_plugins , it seems pretty interesting but I think his solution is too much for what I need. I''ll try to tweak it around to my needs and see if works. Eric Pugh wrote:> I actually realized I need to do the same thing, introduce a > controller in as part of a plugin.. Hollar if you find it first!-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Yes, I was looking at it, and I shy away from plugins depending on plugins. At any rate, I''m in the same boat, so I''d love to hear the solution! On Feb 22, 3:44 pm, Mark <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I found it herehttp://wiki.pluginaweek.org/Appable_plugins, it seems > pretty interesting but I think his solution is too much for what I need. > I''ll try to tweak it around to my needs and see if works. > > Eric Pugh wrote: > > I actually realized I need to do the same thing, introduce a > > controller in as part of a plugin.. Hollar if you find it first! > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I hacked up a solution based on how ajaxscaffoldp does things. I just on startup copy the controller and other shared resources into my app. If I want to extend a controller/resource, then I think I would put that into antoher class so it wouldn''t get overritten. Think of it as "auto generation".... puts "Initiallizing boozer" # copy all the files over to the main rails app, want to avoid .svn source = File.join(directory,''/app/views/sessions'') dest = File.join(RAILS_ROOT, ''/app/views/sessions'') FileUtils.mkdir(dest) unless File.exist?(dest) FileUtils.cp_r(Dir.glob(source+''/*.*''), dest) source = File.join(directory,''/app/controllers'') dest = RAILS_ROOT + ''/app/controllers'' FileUtils.cp_r(Dir.glob(source+''/*.*''), dest) --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Yeah I guess I could do that as well, but I''d prefer having it all inside my plugin''s directory specially because I''m planning on releasing it to the public, and personally, I wouldn''t be happy if I installed a plugin that copied a bunch of files over to my main app. There must be a way to do this approach better, but I''m not sure what it is yet. I''d be great if DHH could give us a hint on that. Eric Pugh wrote:> I hacked up a solution based on how ajaxscaffoldp does things. I just > on startup copy the controller and other shared resources into my > app. If I want to extend a controller/resource, then I think I would > put that into antoher class so it wouldn''t get overritten. Think of > it as "auto generation".... > > puts "Initiallizing boozer" > # copy all the files over to the main rails app, want to avoid .svn > source = File.join(directory,''/app/views/sessions'') > dest = File.join(RAILS_ROOT, ''/app/views/sessions'') > FileUtils.mkdir(dest) unless File.exist?(dest) > FileUtils.cp_r(Dir.glob(source+''/*.*''), dest) > > source = File.join(directory,''/app/controllers'') > dest = RAILS_ROOT + ''/app/controllers'' > FileUtils.cp_r(Dir.glob(source+''/*.*''), dest)-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi,> There must be a way to do this approach better, but I''m not sure what it is yet. >And there are some solutions for that indeed. If you want your controller to use the views only from the plugin, then it''s pretty easy and you''re lucky. You can set in your controller the variable "self.template_root" pointing to the path with the views. Rails will use that for searching the views for your controller, so everything is fine. Problem with this approach comes when you want to display views either from the plugin or from the app directory (or the other way around). Right now, by using the stable versions the only way i know to do that is by reopening a class and adding code of your own. It works, but it''s a bit hackish... BUT... if you don''t mind using edge, then you can take a look at this http://dev.rubyonrails.org/ticket/2754 That way you can have alternative paths for searching the views of any given controller. However, I''d say for the problem you wanted to solve the first solution of using template_root would do. Regards, Javier Ramírez -------- Estamos de estreno... si necesitas llevar el control de tus gastos visita http://www.gastosgem.com !!Es gratis!! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Javier, Thanks a lot. By defining and setting the template_root inside my controller I was able to access the views/helpers within my plugin just fine. javier ramirez wrote:> Hi, >> There must be a way to do this approach better, but I''m not sure what it is yet. >> > And there are some solutions for that indeed. > > If you want your controller to use the views only from the plugin, then > it''s pretty easy and you''re lucky. You can set in your controller the > variable "self.template_root" pointing to the path with the views. Rails > will use that for searching the views for your controller, so everything > is fine. > > Problem with this approach comes when you want to display views either > from the plugin or from the app directory (or the other way around). > > Right now, by using the stable versions the only way i know to do that > is by reopening a class and adding code of your own. It works, but it''s > a bit hackish... BUT... if you don''t mind using edge, then you can take > a look at this http://dev.rubyonrails.org/ticket/2754 > > That way you can have alternative paths for searching the views of any > given controller. However, I''d say for the problem you wanted to solve > the first solution of using template_root would do. > > Regards, > > Javier Ram�rez > > -------- > Estamos de estreno... si necesitas llevar el control de tus gastos > visita http://www.gastosgem.com !!Es gratis!!-- 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---