Map With Controller plugin

Plugin details

I think that the complex Rails applications such as maintained over years tend to have messy config/routes.

With this plugin, it will be easier.

Websitehttp://blog.s21g.com/articles/452 Repositoryhttp://svn.s21g.com/public/rails/plugins/map_with_controller/ Author Genki Takiuchi Tags map LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install http://svn.s21g.com/public/rails/plugins/map_with_controller/

With this plugin, you can draw the routes belonging to some controller like this.

map.with_controller('posts') do |posts|
  posts.rss # posts_rss_path => 'posts/rss'
end



As you can see, there's one more thing. I have also installed MapperWithController class into RouteSet at this plugin for making named routes be completely DRY.

class MapperWithController
  def initialize(mapper)
    @mapper = mapper
  end

  def method_missing(name, *args, &block)
    path, *args = args
    path ||= name.to_s
    args.unshift path
    @mapper.send name, *args, &block
  end
end



map.namespace :posts does nearly same thing, but it couldn't be used for this purpose because of it is optimized to making namespaces for a routing.

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, about 1 month ago