ok This my module which in lib folder
 module Rakelimit
       def self.included(controller)

        controller.extend(ClassMethods)

       end

       module ClassMethods

        def acts_as_rakelimit
             ip = request.remote_ip
            puts ip = local_ip
           minute= (Time.now.to_i / 60).to_i
            checks = Ipcheck.find(:first, :conditions =>[ "ipaddress = ?
and time_min =?", ip,minute] )
            puts checks.inspect
            if checks == nil

Ipcheck.create!(:ipaddress=>ip,:time_min=>minute,:ip_count=>1)
            else
                checks.increment(:ip_count,1).save
                if checks.ip_count >3

                    render_404

           end
            end
        end

         def render_404
               render :file =>"#{RAILS_ROOT}/public/404.html", :status =>
"404 Not Found"

             return false
         end


it's for susbend the process when the person trying more then 3 time if it
increased more then 3 then i would like render 404 error




On Thu, Aug 20, 2009 at 1:28 PM, Frederick Cheung <
[email protected]> wrote:

>
>
>
> On Aug 20, 5:09 am, mahesh <[email protected]> wrote:
> > Im trying render a file 404 from public folder Is possible to render a
> > file from ruby code i have a separate code in the lib file.i got a
> > error like undefined method `render' for AdminController:Class
>
> Well other than saying that you are calling render from somewhere that
> you shouldn't there's not a lot more to be said without seeing what
> you have done.
>
> Fred
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to