Hi Raimon,

Take a look at one of my blog posts on using Camping and OAuth, there a section regarding the use of filters: http://blog.monnet-usa.com/?p=293#caoatodoa
I had packaged Magnus' filtering_camping library as a gem.
You can also see how I use filters in the Camping OAuth plugin: http://github.com/techarch/camping-oauth <http://github.com/techarch/camping-oauth>
See

|To implement filtering:
| 1) |gem install filtering_camping

    2) in your main Camping module add:
        include CampingFilters
|
    3) still in your main module add your global filters:

    before :all do | x |
Camping::Models::Base.logger.debug "[before] filter on #{x.inspect}"
    end

    after :all do
    end

    4) add your controller specific filters

    # when targeting a single controller
    before :MyController1 do
        #your filter logic
    end

    after :MyController1 do
        #your filter logic
    end

    # when targeting multiple controllers use an array
    before [:MyController2, MyController3] do
        #your filter logic
    end

    after [:MyController2, MyController3] do
        #your filter logic
    end

Note you can also use a lambda:

myblock1 = lambda { Camping::Models::Base.logger.debug "hello - before (Index)" }
    before :Index , &myblock1

One of these days I'll write a post on that. ;-)

Philippe (@techarch)

On 10/3/2010 5:21 AM, Raimon Fernandez wrote:
Hi,


I'm trying to use filters in my Camping App, but at this moment they are not 
working ...

I've found some presentation by Jeremy McAnally 
(http://slideshow.rubyforge.org/camping.html#1)

At the end, appears a Library that makes our life easier, but I can't find this 
library.

Also, this presentation is from 2007 and we are now in 2011, so maybe Camping 
can handle those filters in an easy way.

I use them in Rails but here I'm getting always ./list.rb:278: uninitialized 
constant List::Filters (NameError)

Basically what I want to do is before each controller, check if there are some 
input variables in the post, and proceed if they are OK or send an error page, 
well, preferably a an error status in the header.

thanks in advance,

regards,

r.

************************************************************************************************************

Here is what says about Kindling:

Kindling

        • A new library by me that takes the top 5-10 “Railsisms” and lets you 
use them in Camping
        • Currently supports…
                • Easy before/after filters
                • Static file download/upload
                • Easy addition of template handlers, with default support for 
ERb

************************************************************************************************************
_______________________________________________
Camping-list mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/camping-list


_______________________________________________
Camping-list mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/camping-list

Reply via email to