I am working on a Gem for Rails 3 apps. In it, I want to include another GEM/lib/app/config/routes.rb to have gem level access to add new routes non programmatically. i.e., not runtime generated. During Gem initialization I am adding the gem''s lib/app/config dir to $LOAD_PATH and AS''s Dependencies module like so. path = File.join(Rails.root, ''/vendor'', ''sitecontrol'', ''lib'', ''sitecontrol'', ''app'', ''config'') $LOAD_PATH << path ActiveSupport::Dependencies.load_paths << path ActiveSupport::Dependencies.load_once_paths.delete(path) Outputting $LOAD_PATH is showing that the gem''s lib/app/config dir has been added. GEM/lib/app/config/routes.rb looks like this. SitecontrolIntegrationEnv::Application.routes.draw do |map| match ''login'', :to => ''user_sessions#new'' end When running my specs I get "undefined local variable or method `login_path''". If I add the same route to Rails'' standard RAILS/app/ config/routes.rb the spec will pass. How can I go about adding routes in this way from my gem lib? Thanks so much. Elliott G -- 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.
Any thoughts on this one guys? On Jul 28, 12:33 pm, elliottg <x...-+PdThUrr9bOXUBVsB0ZYTw@public.gmane.org> wrote:> I am working on a Gem for Rails 3 apps. In it, I want to include > another GEM/lib/app/config/routes.rb to have gem level access to add > new routes non programmatically. i.e., not runtime generated. > > During Gem initialization I am adding the gem''s lib/app/config dir to > $LOAD_PATH and AS''s Dependencies module like so. > > path = File.join(Rails.root, ''/vendor'', ''sitecontrol'', ''lib'', > ''sitecontrol'', ''app'', ''config'') > $LOAD_PATH << path > ActiveSupport::Dependencies.load_paths << path > ActiveSupport::Dependencies.load_once_paths.delete(path) > > Outputting $LOAD_PATH is showing that the gem''s lib/app/config dir has > been added. > > GEM/lib/app/config/routes.rb looks like this. > > SitecontrolIntegrationEnv::Application.routes.draw do |map| > match ''login'', :to => ''user_sessions#new'' > end > > When running my specs I get "undefined local variable or method > `login_path''". If I add the same route to Rails'' standard RAILS/app/ > config/routes.rb the spec will pass. > > How can I go about adding routes in this way from my gem lib? > > Thanks so much. > Elliott G-- 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.
I solved the problem. I was assuming that since I was duplicating the standard Rails dir structure in my gem that Rails would load files automatically if their parent dir was on $LOAD_PATH. I was wrong. From now on, I will only assume that Rails is loading only one file automatically (rails/ init.rb). My gem is called Sitecontrol... I just added a require ''sitecontrol/ config/routes'' from my gem''s initial lib file (sitecontrol.rb) to the extra routes.rb file I added. On Jul 29, 3:20 pm, elliottg <x...-+PdThUrr9bOXUBVsB0ZYTw@public.gmane.org> wrote:> Any thoughts on this one guys? > > On Jul 28, 12:33 pm, elliottg <x...-+PdThUrr9bOXUBVsB0ZYTw@public.gmane.org> wrote: > > > > > I am working on a Gem for Rails 3 apps. In it, I want to include > > another GEM/lib/app/config/routes.rb to have gem level access to add > > new routes non programmatically. i.e., not runtime generated. > > > During Gem initialization I am adding the gem''s lib/app/config dir to > > $LOAD_PATH and AS''s Dependencies module like so. > > > path = File.join(Rails.root, ''/vendor'', ''sitecontrol'', ''lib'', > > ''sitecontrol'', ''app'', ''config'') > > $LOAD_PATH << path > > ActiveSupport::Dependencies.load_paths << path > > ActiveSupport::Dependencies.load_once_paths.delete(path) > > > Outputting $LOAD_PATH is showing that the gem''s lib/app/config dir has > > been added. > > > GEM/lib/app/config/routes.rb looks like this. > > > SitecontrolIntegrationEnv::Application.routes.draw do |map| > > match ''login'', :to => ''user_sessions#new'' > > end > > > When running my specs I get "undefined local variable or method > > `login_path''". If I add the same route to Rails'' standard RAILS/app/ > > config/routes.rb the spec will pass. > > > How can I go about adding routes in this way from my gem lib? > > > Thanks so much. > > Elliott G-- 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.