# Render a file

**URL:** <https://discuss.rubyonrails.org/t/render-a-file/45310>\
**Category:** rubyonrails-talk\
**Created:** [August 20, 2009, 4:09am UTC](https://discuss.rubyonrails.org/t/render-a-file/45310 "2009-08-20T04:09:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahesh](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@mahesh](https://discuss.rubyonrails.org/u/mahesh)\
**Post date:** [August 20, 2009, 4:09am UTC](https://discuss.rubyonrails.org/t/render-a-file/45310/1 "2009-08-20T04:09:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [August 20, 2009, 7:58am UTC](https://discuss.rubyonrails.org/t/render-a-file/45310/2 "2009-08-20T07:58:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mahesh](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@mahesh](https://discuss.rubyonrails.org/u/mahesh)\
**Post date:** [August 20, 2009, 8:26am UTC](https://discuss.rubyonrails.org/t/render-a-file/45310/3 "2009-08-20T08:26:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [August 20, 2009, 8:31am UTC](https://discuss.rubyonrails.org/t/render-a-file/45310/4 "2009-08-20T08:31:27Z")

</div>

> ```
> def render\_404
> render :file =&gt;&quot;\#\{RAILS\_ROOT\}/public/404\.html&quot;, :status =&gt;
> 
> ```
> 
> "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

---

<div class="post-metadata">

**Author:** ![mahesh](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@mahesh](https://discuss.rubyonrails.org/u/mahesh)\
**Post date:** [August 20, 2009, 8:44am UTC](https://discuss.rubyonrails.org/t/render-a-file/45310/5 "2009-08-20T08:44:34Z")

</div>

ok what will be the solution for me
