Skip to content

ivanvc/routing_params_filters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RoutingParamsFilters
====================

This plugin enables the ability of adding filters, or sending methods to the parameters you are expecting to read from the URL. It's useful if you are expecting to read an integer, a collection of values, etc.

Example
=======

In your routes.rb file:

    ActionController::Routing::Routes.draw do |map|

      map.connect "/something/:something_id",
                :controller => 'some',
                :action     => 'create',
                :conditions => { :method => :post, :something_id => :to_i }
      
      ...
      
    end
  
Then:
    curl -X POST "http://localhost:3000/something/123"
    Parameters: {"action"=>"create", "something_id"=>123, "controller"=>"entries"}

You can even do other things like
    map.connect "/something/:something_id",
              :controller => 'some',
              :action     => 'create',
              :conditions => { :method => :post, :something_id => "split(',')" }

So:
    curl -X POST "http://localhost:3000/something/123,456,789"
    Parameters: {"action"=>"create", "something_id"=>["123","456","789"], "controller"=>"entries"}


Copyright (c) 2010 Ivan Valdes Castillo, released under the MIT license

About

Sends specified methods to the params

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages