Can anyone tell me how to add routes from plugin? I know it is possible because of this changeset: http://dev.rubyonrails.org/changeset/2967 but i didn''t find way how to do it. retro -- Posted via http://www.ruby-forum.com/.
Mihael Konjevic wrote:> Can anyone tell me how to add routes from plugin? I know it is possible > because of this changeset: http://dev.rubyonrails.org/changeset/2967 but > i didn''t find way how to do it. > > retroRemember in Ruby, all clases remain open regardless of the file they are called from. So you should be able to simply mimic the structure of the routes.rb file. #vendor/plugin/foo/lib/foo.rb ActionController::Routing::Routes.draw do |map| map.my_route ''foo/:id'', :controller => ''foo'' end Never done it but it should work, in theory. -- Posted via http://www.ruby-forum.com/.
Good guess but....No, it doesn''t work. I''m looking for a way of doing this as well. I''ve been poking around in the routes code to work out whats going on as yet. It seems alot easier in edge rails. Can anyone shed any light on this? Cheers, Dan On 6/9/06, Alex Wayne <rubyonrails@beautifulpixel.com> wrote:> Mihael Konjevic wrote: > > Can anyone tell me how to add routes from plugin? I know it is possible > > because of this changeset: http://dev.rubyonrails.org/changeset/2967 but > > i didn''t find way how to do it. > > > > retro > > Remember in Ruby, all clases remain open regardless of the file they are > called from. So you should be able to simply mimic the structure of the > routes.rb file. > > #vendor/plugin/foo/lib/foo.rb > ActionController::Routing::Routes.draw do |map| > map.my_route ''foo/:id'', :controller => ''foo'' > end > > Never done it but it should work, in theory. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Dan Webb http://www.danwebb.net
Just curious, did you apply the patch in that changeset? On 6/9/06, Dan Webb <dan@danwebb.net> wrote:> Good guess but....No, it doesn''t work. > > I''m looking for a way of doing this as well. I''ve been poking around > in the routes code to work out whats going on as yet. It seems alot > easier in edge rails. > > Can anyone shed any light on this? > > Cheers, > > Dan > > On 6/9/06, Alex Wayne <rubyonrails@beautifulpixel.com> wrote: > > Mihael Konjevic wrote: > > > Can anyone tell me how to add routes from plugin? I know it is possible > > > because of this changeset: http://dev.rubyonrails.org/changeset/2967 but > > > i didn''t find way how to do it. > > > > > > retro > > > > Remember in Ruby, all clases remain open regardless of the file they are > > called from. So you should be able to simply mimic the structure of the > > routes.rb file. > > > > #vendor/plugin/foo/lib/foo.rb > > ActionController::Routing::Routes.draw do |map| > > map.my_route ''foo/:id'', :controller => ''foo'' > > end > > > > Never done it but it should work, in theory. > > > > -- > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > Dan Webb > http://www.danwebb.net > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
It''s in Rails 1.1 already. It was applied 11/10/05. On 6/9/06, Pat Maddox <pergesu@gmail.com> wrote:> Just curious, did you apply the patch in that changeset? > > On 6/9/06, Dan Webb <dan@danwebb.net> wrote: > > Good guess but....No, it doesn''t work. > > > > I''m looking for a way of doing this as well. I''ve been poking around > > in the routes code to work out whats going on as yet. It seems alot > > easier in edge rails. > > > > Can anyone shed any light on this? > > > > Cheers, > > > > Dan > > > > On 6/9/06, Alex Wayne <rubyonrails@beautifulpixel.com> wrote: > > > Mihael Konjevic wrote: > > > > Can anyone tell me how to add routes from plugin? I know it is possible > > > > because of this changeset: http://dev.rubyonrails.org/changeset/2967 but > > > > i didn''t find way how to do it. > > > > > > > > retro > > > > > > Remember in Ruby, all clases remain open regardless of the file they are > > > called from. So you should be able to simply mimic the structure of the > > > routes.rb file. > > > > > > #vendor/plugin/foo/lib/foo.rb > > > ActionController::Routing::Routes.draw do |map| > > > map.my_route ''foo/:id'', :controller => ''foo'' > > > end > > > > > > Never done it but it should work, in theory. > > > > > > -- > > > Posted via http://www.ruby-forum.com/. > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > -- > > Dan Webb > > http://www.danwebb.net > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Dan Webb http://www.danwebb.net
>From my own investigations earlier in the year, despite the fact thatplugins are loaded before the routing is set up this doesn''t allow the plugins to alter the routing in any trivial fashion i.e. outside of the block passed to Routes.draw. I have seen a plugin add routes by injecting some new functionality directly into the routing mechanism, but this requires a thorough understanding of the routing code, which is in turn hard to obtain since much of it is generated on the fly. Jamis Buck has been discussing a rewrite of this aspect of Rails on the core list recently. So, in a nutshell: it''s possible (because nothing is impossible), but very very difficult. On 6/9/06, Dan Webb <dan@danwebb.net> wrote:> It''s in Rails 1.1 already. It was applied 11/10/05. > > On 6/9/06, Pat Maddox <pergesu@gmail.com> wrote: > > Just curious, did you apply the patch in that changeset? > > > > On 6/9/06, Dan Webb <dan@danwebb.net> wrote: > > > Good guess but....No, it doesn''t work. > > > > > > I''m looking for a way of doing this as well. I''ve been poking around > > > in the routes code to work out whats going on as yet. It seems alot > > > easier in edge rails. > > > > > > Can anyone shed any light on this? > > > > > > Cheers, > > > > > > Dan > > > > > > On 6/9/06, Alex Wayne <rubyonrails@beautifulpixel.com> wrote: > > > > Mihael Konjevic wrote: > > > > > Can anyone tell me how to add routes from plugin? I know it is possible > > > > > because of this changeset: http://dev.rubyonrails.org/changeset/2967 but > > > > > i didn''t find way how to do it. > > > > > > > > > > retro > > > > > > > > Remember in Ruby, all clases remain open regardless of the file they are > > > > called from. So you should be able to simply mimic the structure of the > > > > routes.rb file. > > > > > > > > #vendor/plugin/foo/lib/foo.rb > > > > ActionController::Routing::Routes.draw do |map| > > > > map.my_route ''foo/:id'', :controller => ''foo'' > > > > end > > > > > > > > Never done it but it should work, in theory. > > > > > > > > -- > > > > Posted via http://www.ruby-forum.com/. > > > > _______________________________________________ > > > > Rails mailing list > > > > Rails@lists.rubyonrails.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > > -- > > > Dan Webb > > > http://www.danwebb.net > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > Dan Webb > http://www.danwebb.net > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- * J * ~
That sounds like a challenge! Right then of to the source we go. The annoying thing is that it''s going to be two seperate solutions to the problem. One for 1.1 and one for the rewritten routes in edge rails (although the new routes are much easier to work with) I reckon I can do it though.... On 6/10/06, James Adam <james.adam@gmail.com> wrote:> >From my own investigations earlier in the year, despite the fact that > plugins are loaded before the routing is set up this doesn''t allow the > plugins to alter the routing in any trivial fashion i.e. outside of > the block passed to Routes.draw. > > I have seen a plugin add routes by injecting some new functionality > directly into the routing mechanism, but this requires a thorough > understanding of the routing code, which is in turn hard to obtain > since much of it is generated on the fly. Jamis Buck has been > discussing a rewrite of this aspect of Rails on the core list > recently. > > So, in a nutshell: it''s possible (because nothing is impossible), but > very very difficult. > > On 6/9/06, Dan Webb <dan@danwebb.net> wrote: > > It''s in Rails 1.1 already. It was applied 11/10/05. > > > > On 6/9/06, Pat Maddox <pergesu@gmail.com> wrote: > > > Just curious, did you apply the patch in that changeset? > > > > > > On 6/9/06, Dan Webb <dan@danwebb.net> wrote: > > > > Good guess but....No, it doesn''t work. > > > > > > > > I''m looking for a way of doing this as well. I''ve been poking around > > > > in the routes code to work out whats going on as yet. It seems alot > > > > easier in edge rails. > > > > > > > > Can anyone shed any light on this? > > > > > > > > Cheers, > > > > > > > > Dan > > > > > > > > On 6/9/06, Alex Wayne <rubyonrails@beautifulpixel.com> wrote: > > > > > Mihael Konjevic wrote: > > > > > > Can anyone tell me how to add routes from plugin? I know it is possible > > > > > > because of this changeset: http://dev.rubyonrails.org/changeset/2967 but > > > > > > i didn''t find way how to do it. > > > > > > > > > > > > retro > > > > > > > > > > Remember in Ruby, all clases remain open regardless of the file they are > > > > > called from. So you should be able to simply mimic the structure of the > > > > > routes.rb file. > > > > > > > > > > #vendor/plugin/foo/lib/foo.rb > > > > > ActionController::Routing::Routes.draw do |map| > > > > > map.my_route ''foo/:id'', :controller => ''foo'' > > > > > end > > > > > > > > > > Never done it but it should work, in theory. > > > > > > > > > > -- > > > > > Posted via http://www.ruby-forum.com/. > > > > > _______________________________________________ > > > > > Rails mailing list > > > > > Rails@lists.rubyonrails.org > > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > > > > > > -- > > > > Dan Webb > > > > http://www.danwebb.net > > > > _______________________________________________ > > > > Rails mailing list > > > > Rails@lists.rubyonrails.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > -- > > Dan Webb > > http://www.danwebb.net > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > * J * > ~ > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Dan Webb http://www.danwebb.net
Go Dan, go! ;-) -Ezra On Jun 10, 2006, at 7:16 AM, Dan Webb wrote:> That sounds like a challenge! Right then of to the source we go. > > The annoying thing is that it''s going to be two seperate solutions to > the problem. One for 1.1 and one for the rewritten routes in edge > rails (although the new routes are much easier to work with) > > I reckon I can do it though.... > > On 6/10/06, James Adam <james.adam@gmail.com> wrote: >> >From my own investigations earlier in the year, despite the fact >> that >> plugins are loaded before the routing is set up this doesn''t allow >> the >> plugins to alter the routing in any trivial fashion i.e. outside of >> the block passed to Routes.draw. >> >> I have seen a plugin add routes by injecting some new functionality >> directly into the routing mechanism, but this requires a thorough >> understanding of the routing code, which is in turn hard to obtain >> since much of it is generated on the fly. Jamis Buck has been >> discussing a rewrite of this aspect of Rails on the core list >> recently. >> >> So, in a nutshell: it''s possible (because nothing is impossible), but >> very very difficult. >> >> On 6/9/06, Dan Webb <dan@danwebb.net> wrote: >> > It''s in Rails 1.1 already. It was applied 11/10/05. >> > >> > On 6/9/06, Pat Maddox <pergesu@gmail.com> wrote: >> > > Just curious, did you apply the patch in that changeset? >> > > >> > > On 6/9/06, Dan Webb <dan@danwebb.net> wrote: >> > > > Good guess but....No, it doesn''t work. >> > > > >> > > > I''m looking for a way of doing this as well. I''ve been >> poking around >> > > > in the routes code to work out whats going on as yet. It >> seems alot >> > > > easier in edge rails. >> > > > >> > > > Can anyone shed any light on this? >> > > > >> > > > Cheers, >> > > > >> > > > Dan >> > > > >> > > > On 6/9/06, Alex Wayne <rubyonrails@beautifulpixel.com> wrote: >> > > > > Mihael Konjevic wrote: >> > > > > > Can anyone tell me how to add routes from plugin? I know >> it is possible >> > > > > > because of this changeset: http://dev.rubyonrails.org/ >> changeset/2967 but >> > > > > > i didn''t find way how to do it. >> > > > > > >> > > > > > retro >> > > > > >> > > > > Remember in Ruby, all clases remain open regardless of the >> file they are >> > > > > called from. So you should be able to simply mimic the >> structure of the >> > > > > routes.rb file. >> > > > > >> > > > > #vendor/plugin/foo/lib/foo.rb >> > > > > ActionController::Routing::Routes.draw do |map| >> > > > > map.my_route ''foo/:id'', :controller => ''foo'' >> > > > > end >> > > > > >> > > > > Never done it but it should work, in theory. >> > > > > >> > > > > -- >> > > > > Posted via http://www.ruby-forum.com/. >> > > > > _______________________________________________ >> > > > > Rails mailing list >> > > > > Rails@lists.rubyonrails.org >> > > > > http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > > >> > > > >> > > > >> > > > -- >> > > > Dan Webb >> > > > http://www.danwebb.net >> > > > _______________________________________________ >> > > > Rails mailing list >> > > > Rails@lists.rubyonrails.org >> > > > http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > >> > > _______________________________________________ >> > > Rails mailing list >> > > Rails@lists.rubyonrails.org >> > > http://lists.rubyonrails.org/mailman/listinfo/rails >> > > >> > >> > >> > -- >> > Dan Webb >> > http://www.danwebb.net >> > _______________________________________________ >> > Rails mailing list >> > Rails@lists.rubyonrails.org >> > http://lists.rubyonrails.org/mailman/listinfo/rails >> > >> >> >> -- >> * J * >> ~ >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > -- > Dan Webb > http://www.danwebb.net > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
You can do it, put your hack into it. ahem. - james On 6/10/06, Ezra Zygmuntowicz <ezmobius@gmail.com> wrote:> > Go Dan, go! ;-) > > -Ezra > > On Jun 10, 2006, at 7:16 AM, Dan Webb wrote: > > > That sounds like a challenge! Right then of to the source we go. > > > > The annoying thing is that it''s going to be two seperate solutions to > > the problem. One for 1.1 and one for the rewritten routes in edge > > rails (although the new routes are much easier to work with) > > > > I reckon I can do it though.... > > > > On 6/10/06, James Adam <james.adam@gmail.com> wrote: > >> >From my own investigations earlier in the year, despite the fact > >> that > >> plugins are loaded before the routing is set up this doesn''t allow > >> the > >> plugins to alter the routing in any trivial fashion i.e. outside of > >> the block passed to Routes.draw. > >> > >> I have seen a plugin add routes by injecting some new functionality > >> directly into the routing mechanism, but this requires a thorough > >> understanding of the routing code, which is in turn hard to obtain > >> since much of it is generated on the fly. Jamis Buck has been > >> discussing a rewrite of this aspect of Rails on the core list > >> recently. > >> > >> So, in a nutshell: it''s possible (because nothing is impossible), but > >> very very difficult. > >> > >> On 6/9/06, Dan Webb <dan@danwebb.net> wrote: > >> > It''s in Rails 1.1 already. It was applied 11/10/05. > >> > > >> > On 6/9/06, Pat Maddox <pergesu@gmail.com> wrote: > >> > > Just curious, did you apply the patch in that changeset? > >> > > > >> > > On 6/9/06, Dan Webb <dan@danwebb.net> wrote: > >> > > > Good guess but....No, it doesn''t work. > >> > > > > >> > > > I''m looking for a way of doing this as well. I''ve been > >> poking around > >> > > > in the routes code to work out whats going on as yet. It > >> seems alot > >> > > > easier in edge rails. > >> > > > > >> > > > Can anyone shed any light on this? > >> > > > > >> > > > Cheers, > >> > > > > >> > > > Dan > >> > > > > >> > > > On 6/9/06, Alex Wayne <rubyonrails@beautifulpixel.com> wrote: > >> > > > > Mihael Konjevic wrote: > >> > > > > > Can anyone tell me how to add routes from plugin? I know > >> it is possible > >> > > > > > because of this changeset: http://dev.rubyonrails.org/ > >> changeset/2967 but > >> > > > > > i didn''t find way how to do it. > >> > > > > > > >> > > > > > retro > >> > > > > > >> > > > > Remember in Ruby, all clases remain open regardless of the > >> file they are > >> > > > > called from. So you should be able to simply mimic the > >> structure of the > >> > > > > routes.rb file. > >> > > > > > >> > > > > #vendor/plugin/foo/lib/foo.rb > >> > > > > ActionController::Routing::Routes.draw do |map| > >> > > > > map.my_route ''foo/:id'', :controller => ''foo'' > >> > > > > end > >> > > > > > >> > > > > Never done it but it should work, in theory. > >> > > > > > >> > > > > -- > >> > > > > Posted via http://www.ruby-forum.com/. > >> > > > > _______________________________________________ > >> > > > > Rails mailing list > >> > > > > Rails@lists.rubyonrails.org > >> > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > > > > >> > > > > >> > > > > >> > > > -- > >> > > > Dan Webb > >> > > > http://www.danwebb.net > >> > > > _______________________________________________ > >> > > > Rails mailing list > >> > > > Rails@lists.rubyonrails.org > >> > > > http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > > > >> > > _______________________________________________ > >> > > Rails mailing list > >> > > Rails@lists.rubyonrails.org > >> > > http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > > >> > > >> > > >> > -- > >> > Dan Webb > >> > http://www.danwebb.net > >> > _______________________________________________ > >> > Rails mailing list > >> > Rails@lists.rubyonrails.org > >> > http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > >> > >> > >> -- > >> * J * > >> ~ > >> _______________________________________________ > >> Rails mailing list > >> Rails@lists.rubyonrails.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > > > > > -- > > Dan Webb > > http://www.danwebb.net > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- * J * ~
Ha ha, excellent pun action. Been looking at it this weekend and was thinking of a patch(or plugin or whatever) that allows a routes.rb to be specified in a plugin directory. When reload! is called it will load the plugin routes, then load the main routes...what do you all reckon? Is that a good approach? On 6/11/06, James Adam <james.adam@gmail.com> wrote:> You can do it, put your hack into it. > > ahem. > > - james > > On 6/10/06, Ezra Zygmuntowicz <ezmobius@gmail.com> wrote: > > > > Go Dan, go! ;-) > > > > -Ezra > > > > On Jun 10, 2006, at 7:16 AM, Dan Webb wrote: > > > > > That sounds like a challenge! Right then of to the source we go. > > > > > > The annoying thing is that it''s going to be two seperate solutions to > > > the problem. One for 1.1 and one for the rewritten routes in edge > > > rails (although the new routes are much easier to work with) > > > > > > I reckon I can do it though.... > > > > > > On 6/10/06, James Adam <james.adam@gmail.com> wrote: > > >> >From my own investigations earlier in the year, despite the fact > > >> that > > >> plugins are loaded before the routing is set up this doesn''t allow > > >> the > > >> plugins to alter the routing in any trivial fashion i.e. outside of > > >> the block passed to Routes.draw. > > >> > > >> I have seen a plugin add routes by injecting some new functionality > > >> directly into the routing mechanism, but this requires a thorough > > >> understanding of the routing code, which is in turn hard to obtain > > >> since much of it is generated on the fly. Jamis Buck has been > > >> discussing a rewrite of this aspect of Rails on the core list > > >> recently. > > >> > > >> So, in a nutshell: it''s possible (because nothing is impossible), but > > >> very very difficult. > > >> > > >> On 6/9/06, Dan Webb <dan@danwebb.net> wrote: > > >> > It''s in Rails 1.1 already. It was applied 11/10/05. > > >> > > > >> > On 6/9/06, Pat Maddox <pergesu@gmail.com> wrote: > > >> > > Just curious, did you apply the patch in that changeset? > > >> > > > > >> > > On 6/9/06, Dan Webb <dan@danwebb.net> wrote: > > >> > > > Good guess but....No, it doesn''t work. > > >> > > > > > >> > > > I''m looking for a way of doing this as well. I''ve been > > >> poking around > > >> > > > in the routes code to work out whats going on as yet. It > > >> seems alot > > >> > > > easier in edge rails. > > >> > > > > > >> > > > Can anyone shed any light on this? > > >> > > > > > >> > > > Cheers, > > >> > > > > > >> > > > Dan > > >> > > > > > >> > > > On 6/9/06, Alex Wayne <rubyonrails@beautifulpixel.com> wrote: > > >> > > > > Mihael Konjevic wrote: > > >> > > > > > Can anyone tell me how to add routes from plugin? I know > > >> it is possible > > >> > > > > > because of this changeset: http://dev.rubyonrails.org/ > > >> changeset/2967 but > > >> > > > > > i didn''t find way how to do it. > > >> > > > > > > > >> > > > > > retro > > >> > > > > > > >> > > > > Remember in Ruby, all clases remain open regardless of the > > >> file they are > > >> > > > > called from. So you should be able to simply mimic the > > >> structure of the > > >> > > > > routes.rb file. > > >> > > > > > > >> > > > > #vendor/plugin/foo/lib/foo.rb > > >> > > > > ActionController::Routing::Routes.draw do |map| > > >> > > > > map.my_route ''foo/:id'', :controller => ''foo'' > > >> > > > > end > > >> > > > > > > >> > > > > Never done it but it should work, in theory. > > >> > > > > > > >> > > > > -- > > >> > > > > Posted via http://www.ruby-forum.com/. > > >> > > > > _______________________________________________ > > >> > > > > Rails mailing list > > >> > > > > Rails@lists.rubyonrails.org > > >> > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > >> > > > > > > >> > > > > > >> > > > > > >> > > > -- > > >> > > > Dan Webb > > >> > > > http://www.danwebb.net > > >> > > > _______________________________________________ > > >> > > > Rails mailing list > > >> > > > Rails@lists.rubyonrails.org > > >> > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > >> > > > > > >> > > _______________________________________________ > > >> > > Rails mailing list > > >> > > Rails@lists.rubyonrails.org > > >> > > http://lists.rubyonrails.org/mailman/listinfo/rails > > >> > > > > >> > > > >> > > > >> > -- > > >> > Dan Webb > > >> > http://www.danwebb.net > > >> > _______________________________________________ > > >> > Rails mailing list > > >> > Rails@lists.rubyonrails.org > > >> > http://lists.rubyonrails.org/mailman/listinfo/rails > > >> > > > >> > > >> > > >> -- > > >> * J * > > >> ~ > > >> _______________________________________________ > > >> Rails mailing list > > >> Rails@lists.rubyonrails.org > > >> http://lists.rubyonrails.org/mailman/listinfo/rails > > >> > > > > > > > > > -- > > > Dan Webb > > > http://www.danwebb.net > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > * J * > ~ > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Dan Webb http://www.danwebb.net
I think the key issue when you''re considering routing with plugins (beyond actually making it work) is precidence. Because the plugin load order is currently at the whim and mercy of the filesystem, it may be problematic ensuring that the routes you define within plugin X aren''t going to have a lower precidence that some which conincidentally match from plugin Y. I have in mind a patch to control plugin loading order because it''s something I know that I would find useful, but even with this routing would still be a bit swampy - you''d have to inspect each plugin for potentially nasty routes and double-check the precidence yourself (hard enough when they''re all in a single file, sometimes). That said, I''d still like it to be possible. When you''re developing plugins/engines for internal use only, these kind of issues are more managable, and the benefits might outweigh the hassle. Dan - If you''re at the LRUG meeting tomorrow, we can try and bash something out. - james On 6/11/06, Dan Webb <dan@danwebb.net> wrote:> Ha ha, excellent pun action. > > Been looking at it this weekend and was thinking of a patch(or plugin > or whatever) that allows a routes.rb to be specified in a plugin > directory. When reload! is called it will load the plugin routes, > then load the main routes...what do you all reckon? Is that a good > approach? > > On 6/11/06, James Adam <james.adam@gmail.com> wrote: > > You can do it, put your hack into it. > > > > ahem. > > > > - james > > > > On 6/10/06, Ezra Zygmuntowicz <ezmobius@gmail.com> wrote: > > > > > > Go Dan, go! ;-) > > > > > > -Ezra > > > > > > On Jun 10, 2006, at 7:16 AM, Dan Webb wrote: > > > > > > > That sounds like a challenge! Right then of to the source we go. > > > > > > > > The annoying thing is that it''s going to be two seperate solutions to > > > > the problem. One for 1.1 and one for the rewritten routes in edge > > > > rails (although the new routes are much easier to work with) > > > > > > > > I reckon I can do it though.... > > > > > > > > On 6/10/06, James Adam <james.adam@gmail.com> wrote: > > > >> >From my own investigations earlier in the year, despite the fact > > > >> that > > > >> plugins are loaded before the routing is set up this doesn''t allow > > > >> the > > > >> plugins to alter the routing in any trivial fashion i.e. outside of > > > >> the block passed to Routes.draw. > > > >> > > > >> I have seen a plugin add routes by injecting some new functionality > > > >> directly into the routing mechanism, but this requires a thorough > > > >> understanding of the routing code, which is in turn hard to obtain > > > >> since much of it is generated on the fly. Jamis Buck has been > > > >> discussing a rewrite of this aspect of Rails on the core list > > > >> recently. > > > >> > > > >> So, in a nutshell: it''s possible (because nothing is impossible), but > > > >> very very difficult. > > > >> > > > >> On 6/9/06, Dan Webb <dan@danwebb.net> wrote: > > > >> > It''s in Rails 1.1 already. It was applied 11/10/05. > > > >> > > > > >> > On 6/9/06, Pat Maddox <pergesu@gmail.com> wrote: > > > >> > > Just curious, did you apply the patch in that changeset? > > > >> > > > > > >> > > On 6/9/06, Dan Webb <dan@danwebb.net> wrote: > > > >> > > > Good guess but....No, it doesn''t work. > > > >> > > > > > > >> > > > I''m looking for a way of doing this as well. I''ve been > > > >> poking around > > > >> > > > in the routes code to work out whats going on as yet. It > > > >> seems alot > > > >> > > > easier in edge rails. > > > >> > > > > > > >> > > > Can anyone shed any light on this? > > > >> > > > > > > >> > > > Cheers, > > > >> > > > > > > >> > > > Dan > > > >> > > > > > > >> > > > On 6/9/06, Alex Wayne <rubyonrails@beautifulpixel.com> wrote: > > > >> > > > > Mihael Konjevic wrote: > > > >> > > > > > Can anyone tell me how to add routes from plugin? I know > > > >> it is possible > > > >> > > > > > because of this changeset: http://dev.rubyonrails.org/ > > > >> changeset/2967 but > > > >> > > > > > i didn''t find way how to do it. > > > >> > > > > > > > > >> > > > > > retro > > > >> > > > > > > > >> > > > > Remember in Ruby, all clases remain open regardless of the > > > >> file they are > > > >> > > > > called from. So you should be able to simply mimic the > > > >> structure of the > > > >> > > > > routes.rb file. > > > >> > > > > > > > >> > > > > #vendor/plugin/foo/lib/foo.rb > > > >> > > > > ActionController::Routing::Routes.draw do |map| > > > >> > > > > map.my_route ''foo/:id'', :controller => ''foo'' > > > >> > > > > end > > > >> > > > > > > > >> > > > > Never done it but it should work, in theory. > > > >> > > > > > > > >> > > > > -- > > > >> > > > > Posted via http://www.ruby-forum.com/. > > > >> > > > > _______________________________________________ > > > >> > > > > Rails mailing list > > > >> > > > > Rails@lists.rubyonrails.org > > > >> > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >> > > > > > > > >> > > > > > > >> > > > > > > >> > > > -- > > > >> > > > Dan Webb > > > >> > > > http://www.danwebb.net > > > >> > > > _______________________________________________ > > > >> > > > Rails mailing list > > > >> > > > Rails@lists.rubyonrails.org > > > >> > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >> > > > > > > >> > > _______________________________________________ > > > >> > > Rails mailing list > > > >> > > Rails@lists.rubyonrails.org > > > >> > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >> > > > > > >> > > > > >> > > > > >> > -- > > > >> > Dan Webb > > > >> > http://www.danwebb.net > > > >> > _______________________________________________ > > > >> > Rails mailing list > > > >> > Rails@lists.rubyonrails.org > > > >> > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >> > > > > >> > > > >> > > > >> -- > > > >> * J * > > > >> ~ > > > >> _______________________________________________ > > > >> Rails mailing list > > > >> Rails@lists.rubyonrails.org > > > >> http://lists.rubyonrails.org/mailman/listinfo/rails > > > >> > > > > > > > > > > > > -- > > > > Dan Webb > > > > http://www.danwebb.net > > > > _______________________________________________ > > > > Rails mailing list > > > > Rails@lists.rubyonrails.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > -- > > * J * > > ~ > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > Dan Webb > http://www.danwebb.net > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- * J * ~
Okay, yeah, I''ll come along tomorrow. I know what you mean about precidence, it''s a big problem. I''ve got a very specific use case for what I''m trying to do at the moment but to generalise it will be difficult. Anyway, speak to you tomorrow. On 6/11/06, James Adam <james.adam@gmail.com> wrote:> I think the key issue when you''re considering routing with plugins > (beyond actually making it work) is precidence. Because the plugin > load order is currently at the whim and mercy of the filesystem, it > may be problematic ensuring that the routes you define within plugin X > aren''t going to have a lower precidence that some which > conincidentally match from plugin Y. > > I have in mind a patch to control plugin loading order because it''s > something I know that I would find useful, but even with this routing > would still be a bit swampy - you''d have to inspect each plugin for > potentially nasty routes and double-check the precidence yourself > (hard enough when they''re all in a single file, sometimes). > > That said, I''d still like it to be possible. When you''re developing > plugins/engines for internal use only, these kind of issues are more > managable, and the benefits might outweigh the hassle. > > Dan - If you''re at the LRUG meeting tomorrow, we can try and bash something out. > > - james > > On 6/11/06, Dan Webb <dan@danwebb.net> wrote: > > Ha ha, excellent pun action. > > > > Been looking at it this weekend and was thinking of a patch(or plugin > > or whatever) that allows a routes.rb to be specified in a plugin > > directory. When reload! is called it will load the plugin routes, > > then load the main routes...what do you all reckon? Is that a good > > approach? > > > > On 6/11/06, James Adam <james.adam@gmail.com> wrote: > > > You can do it, put your hack into it. > > > > > > ahem. > > > > > > - james > > > > > > On 6/10/06, Ezra Zygmuntowicz <ezmobius@gmail.com> wrote: > > > > > > > > Go Dan, go! ;-) > > > > > > > > -Ezra > > > > > > > > On Jun 10, 2006, at 7:16 AM, Dan Webb wrote: > > > > > > > > > That sounds like a challenge! Right then of to the source we go. > > > > > > > > > > The annoying thing is that it''s going to be two seperate solutions to > > > > > the problem. One for 1.1 and one for the rewritten routes in edge > > > > > rails (although the new routes are much easier to work with) > > > > > > > > > > I reckon I can do it though.... > > > > > > > > > > On 6/10/06, James Adam <james.adam@gmail.com> wrote: > > > > >> >From my own investigations earlier in the year, despite the fact > > > > >> that > > > > >> plugins are loaded before the routing is set up this doesn''t allow > > > > >> the > > > > >> plugins to alter the routing in any trivial fashion i.e. outside of > > > > >> the block passed to Routes.draw. > > > > >> > > > > >> I have seen a plugin add routes by injecting some new functionality > > > > >> directly into the routing mechanism, but this requires a thorough > > > > >> understanding of the routing code, which is in turn hard to obtain > > > > >> since much of it is generated on the fly. Jamis Buck has been > > > > >> discussing a rewrite of this aspect of Rails on the core list > > > > >> recently. > > > > >> > > > > >> So, in a nutshell: it''s possible (because nothing is impossible), but > > > > >> very very difficult. > > > > >> > > > > >> On 6/9/06, Dan Webb <dan@danwebb.net> wrote: > > > > >> > It''s in Rails 1.1 already. It was applied 11/10/05. > > > > >> > > > > > >> > On 6/9/06, Pat Maddox <pergesu@gmail.com> wrote: > > > > >> > > Just curious, did you apply the patch in that changeset? > > > > >> > > > > > > >> > > On 6/9/06, Dan Webb <dan@danwebb.net> wrote: > > > > >> > > > Good guess but....No, it doesn''t work. > > > > >> > > > > > > > >> > > > I''m looking for a way of doing this as well. I''ve been > > > > >> poking around > > > > >> > > > in the routes code to work out whats going on as yet. It > > > > >> seems alot > > > > >> > > > easier in edge rails. > > > > >> > > > > > > > >> > > > Can anyone shed any light on this? > > > > >> > > > > > > > >> > > > Cheers, > > > > >> > > > > > > > >> > > > Dan > > > > >> > > > > > > > >> > > > On 6/9/06, Alex Wayne <rubyonrails@beautifulpixel.com> wrote: > > > > >> > > > > Mihael Konjevic wrote: > > > > >> > > > > > Can anyone tell me how to add routes from plugin? I know > > > > >> it is possible > > > > >> > > > > > because of this changeset: http://dev.rubyonrails.org/ > > > > >> changeset/2967 but > > > > >> > > > > > i didn''t find way how to do it. > > > > >> > > > > > > > > > >> > > > > > retro > > > > >> > > > > > > > > >> > > > > Remember in Ruby, all clases remain open regardless of the > > > > >> file they are > > > > >> > > > > called from. So you should be able to simply mimic the > > > > >> structure of the > > > > >> > > > > routes.rb file. > > > > >> > > > > > > > > >> > > > > #vendor/plugin/foo/lib/foo.rb > > > > >> > > > > ActionController::Routing::Routes.draw do |map| > > > > >> > > > > map.my_route ''foo/:id'', :controller => ''foo'' > > > > >> > > > > end > > > > >> > > > > > > > > >> > > > > Never done it but it should work, in theory. > > > > >> > > > > > > > > >> > > > > -- > > > > >> > > > > Posted via http://www.ruby-forum.com/. > > > > >> > > > > _______________________________________________ > > > > >> > > > > Rails mailing list > > > > >> > > > > Rails@lists.rubyonrails.org > > > > >> > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > >> > > > > > > > > >> > > > > > > > >> > > > > > > > >> > > > -- > > > > >> > > > Dan Webb > > > > >> > > > http://www.danwebb.net > > > > >> > > > _______________________________________________ > > > > >> > > > Rails mailing list > > > > >> > > > Rails@lists.rubyonrails.org > > > > >> > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > >> > > > > > > > >> > > _______________________________________________ > > > > >> > > Rails mailing list > > > > >> > > Rails@lists.rubyonrails.org > > > > >> > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > >> > > > > > > >> > > > > > >> > > > > > >> > -- > > > > >> > Dan Webb > > > > >> > http://www.danwebb.net > > > > >> > _______________________________________________ > > > > >> > Rails mailing list > > > > >> > Rails@lists.rubyonrails.org > > > > >> > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > >> > > > > > >> > > > > >> > > > > >> -- > > > > >> * J * > > > > >> ~ > > > > >> _______________________________________________ > > > > >> Rails mailing list > > > > >> Rails@lists.rubyonrails.org > > > > >> http://lists.rubyonrails.org/mailman/listinfo/rails > > > > >> > > > > > > > > > > > > > > > -- > > > > > Dan Webb > > > > > http://www.danwebb.net > > > > > _______________________________________________ > > > > > Rails mailing list > > > > > Rails@lists.rubyonrails.org > > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > _______________________________________________ > > > > Rails mailing list > > > > Rails@lists.rubyonrails.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > > -- > > > * J * > > > ~ > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > -- > > Dan Webb > > http://www.danwebb.net > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > * J * > ~ > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Dan Webb http://www.danwebb.net