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
On Aug 20, 5:09 am, mahesh <mahesh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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:ClassWell 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
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 < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Aug 20, 5:09 am, mahesh <mahesh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Aug 20, 9:26 am, mahesh s <mahesh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 errorThese shouldn''t be class methods. This is all about dealing with an individual request, which only makes sense in the context of an instance method Fred> > On Thu, Aug 20, 2009 at 1:28 PM, Frederick Cheung < > > > > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Aug 20, 5:09 am, mahesh <mahesh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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
ok what will be the solution for me On Thu, Aug 20, 2009 at 2:01 PM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Aug 20, 9:26 am, mahesh s <mahesh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > 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 > > These shouldn''t be class methods. This is all about dealing with an > individual request, which only makes sense in the context of an > instance method > > Fred > > > > > > On Thu, Aug 20, 2009 at 1:28 PM, Frederick Cheung < > > > > > > > > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Aug 20, 5:09 am, mahesh <mahesh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---