Ruby on Rails Thursday, July 29, 2010

Any thoughts on this one guys?

On Jul 28, 12:33 pm, elliottg <x...@simplecircle.net> 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@googlegroups.com.
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.

No comments:

Post a Comment