Plugin: validate_request

July 26, 2006 at 5:28 am Leave a comment

A very useful plugin by Scott A. Woods.

validate_request plugin allows us to check the request method and parameters that are used to call your action.

For Example consider an add_to_cart action as:

  def add_to_cart
    @product = Product.find(params[:id])

The link to add an item to our cart should like store/add_to_cart/nnn, where nnn is an integer. There will be an error if some one intentionaly enter store/add_to_cart/some_string_here.
ValidateRequest allows us to double check these things, and act appropriately. For instance, we could solve the above problem by adding one line to our action:

  def add_to_cart
    validate_request(:get, :id => :integer) or return
    @product = Product.find(params[:id])

The validate_request method will now verify that incoming requests are via the GET method, and that they contain one argument called ‘id’ whose value is an integer. If any of these conditions aren’t true, the requester is redirected to the site’s home page (configurable, of course), and flash[:error] is set with a polite message (also configurable).

Install the plugin by running the following commands from your rails application’s directory:

./script/plugin source svn:// ./script/plugin install validate_request

For more details visit

Entry filed under: rails, rails plugins, Ruby, RubyonRails. Tags: .

Plugin: tabnav Make ids in URL Search engine friendly

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed

Important Notice…

I have moved this blog to . I will continue posting at, not on

Kindly update your book marks to

and .

I am really very sorry for inconvenience.

Comming Soon….

Domain for Sale

(Contact me)

Recent Posts


July 2006
« Jun   Aug »


  • Add to Google
  • Subscribe in NewsGator Online
  • Subscribe with Bloglines
  • WebOnRails on feedburner
  • technorati


Flickr Photos

A bellezza di a natura (C☺rsica)

JWL5932 Mountain Hare..

Black and Gold

More Photos

Visitor’s Location

Blog Stats

  • 17,978 hits

%d bloggers like this: