# Replace\_html not working

**URL:** <https://www.ruby-forum.com/t/replace-html-not-working/150875>\
**Category:** Rails\
**Created:** [October 14, 2008, 1:39pm UTC](https://www.ruby-forum.com/t/replace-html-not-working/150875 "2008-10-14T13:39:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yell13](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ecd19e/32.png) [@yell13](https://www.ruby-forum.com/u/yell13)\
**Post date:** [October 14, 2008, 1:39pm UTC](https://www.ruby-forum.com/t/replace-html-not-working/150875/1 "2008-10-14T13:39:36Z")

</div>

hallo, everyone

can anybody help me? i did add my code under ENGINES as a module in a  
project. before the change , all worked . and the differenz between  
both is only about application’s environment,  
before is

Ruby version 1.8.6 (i486-linux)  
RubyGems version 1.1.1  
Rails version 2.0.2  
Active Record version 2.0.2  
Action Pack version 2.0.2  
Active Resource version 2.0.2  
Action Mailer version 2.0.2  
Active Support version 2.0.2  
Application root /home/kiki/workspace/xxx  
Environment development  
Database adapter mysql  
Database schema version 0

now is

Ruby version 1.8.6 (i486-linux)  
RubyGems version 1.1.1  
Rails version 2.1.0  
Active Record version 2.1.0  
Action Pack version 2.1.0  
Active Resource version 2.1.0  
Action Mailer version 2.1.0  
Active Support version 2.1.0  
Application root /home/kiki/workspace/xxxx/  
Environment development  
Database adapter sqlite3  
Database schema version 0

and now all function about replace of page not working . maybe the under  
informations is helpable.

tail -f log/development.log

```
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/configurator.rb:282:in

```

`run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/configurator.rb:281:in`each’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/…/lib/mongrel/configurator.rb:281:in  
`run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:128:in`run’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/…/lib/mongrel/command.rb:212:in  
`run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:281 /usr/bin/mongrel_rails:19:in`load’  
/usr/bin/mongrel\_rails:19

Rendering  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/templates/rescues/layout.erb  
(internal\_server\_error)

and the information , when i select a month .

Processing AccountsController#filtered\_balances\_for\_a\_month (for  
127.0.0.1 at 2008-10-14 13:05:31) [POST]  
Session ID:  
BAh7CToUcmV0dXJuX2xvY2F0aW9uQzoeSGFzaFdpdGhJbmRpZmZlcmVudEFj  
Y2Vzc3sJIgxzaXRlX2lkIgYyIgthY3Rpb24iCXNob3ciB2lkIgYxIg9jb250  
cm9sbGVyIhBhZG1pbi91c2VyczoMY3NyZl9pZCIlOWIyNWYwMzk5ZmFiMjZh  
MjhiNmNhMDBhNDkyY2NhNjU6CHVpZGkGIgpmbGFzaElDOidBY3Rpb25Db250  
cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA–1a0684d271aa6103b52dbc61c4ad7560443a7f6e  
Parameters: {“commit”=\>“Filter balances for a month”,  
“chartofaccount\_id”=\>“1”,  
“authenticity\_token”=\>“388f45d590a6a0692313241db3f16ee5a5b3b896”,  
“action”=\>“filtered\_balances\_for\_a\_month”,  
“filter”=\>{“month(1i)”=\>“2008”, “month(2i)”=\>“9”, “month(3i)”=\>“1”},  
“controller”=\>“accounts”}  
Chartofaccount Load (0.000290) SELECT \* FROM “chartofaccounts” WHERE  
(“chartofaccounts”.“id” = 1)  
Account Load (0.001298) SELECT \* FROM “accounts” WHERE  
(chartofaccount\_id=1) ORDER BY code ASC

ArgumentError (tried to create Proc object without a block):  
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active\_support/core\_ext/object/extending.rb:46:in  
`define_method' /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/object/extending.rb:46:in`instance\_exec’  
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active\_support/core\_ext/object/extending.rb:46:in  
`module_eval' /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/object/extending.rb:46:in`instance\_exec’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_view/helpers/prototype\_helper.rb:581:in  
`initialize' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:913:in`new’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/base.rb:913:in  
`render_with_no_layout' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/layout.rb:259:in`render\_without\_benchmark’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/benchmarking.rb:51:in  
`render_without_error_proc' /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/benchmark.rb:8:in`realtime’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/benchmarking.rb:51:in  
`render_without_error_proc' /vendor/plugins/render_with_error_proc/lib/action_controller/render_with_error_proc.rb:26:in`render’  
/vendor/plugins/render\_with\_error\_proc/lib/action\_controller/render\_with\_error\_proc.rb:45:in  
`with_error_proc' /vendor/plugins/render_with_error_proc/lib/action_controller/render_with_error_proc.rb:25:in`render’  
/vendor/engines/adva\_pac/app/controllers/accounts\_controller.rb:225:in  
`filtered_balances_for_a_month' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:1162:in`send’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/base.rb:1162:in  
`perform_action_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/filters.rb:580:in`call\_filters’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/filters.rb:573:in  
`perform_action_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/benchmarking.rb:68:in`perform\_action\_without\_rescue’  
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/benchmarking.rb:68:in`perform\_action\_without\_rescue’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/rescue.rb:201:in  
`perform_action_without_caching' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/caching/sql_cache.rb:13:in`perform\_action’  
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active\_record/connection\_adapters/abstract/query\_cache.rb:33:in  
`cache' /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/query_cache.rb:8:in`cache’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/caching/sql\_cache.rb:12:in  
`perform_action' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:529:in`send’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/base.rb:529:in  
`process_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/filters.rb:569:in`process\_without\_session\_management\_support’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/session\_management.rb:130:in  
`process' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:389:in`process’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/dispatcher.rb:149:in  
`handle_request' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:107:in`dispatch’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/dispatcher.rb:104:in  
`synchronize' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:104:in`dispatch’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/dispatcher.rb:120:in  
`dispatch_cgi' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:35:in`dispatch’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/…/lib/mongrel/rails.rb:76:in  
`process' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/rails.rb:74:in`synchronize’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/…/lib/mongrel/rails.rb:74:in  
`process' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:159:in`process\_client’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/…/lib/mongrel.rb:158:in  
`each' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:158:in`process\_client’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/…/lib/mongrel.rb:285:in  
`run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:285:in`initialize’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/…/lib/mongrel.rb:285:in  
`new' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:285:in`run’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/…/lib/mongrel.rb:268:in  
`initialize' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:268:in`new’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/…/lib/mongrel.rb:268:in  
`run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/configurator.rb:282:in`run’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/…/lib/mongrel/configurator.rb:281:in  
`each' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/configurator.rb:281:in`run’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel\_rails:128:in  
`run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/command.rb:212:in`run’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel\_rails:281  
/usr/bin/mongrel\_rails:19:in `load’  
/usr/bin/mongrel\_rails:19

Rendering  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/templates/rescues/layout.erb  
(internal\_server\_error)

---

<div class="post-metadata">

**Author:** ![yell13](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ecd19e/32.png) [@yell13](https://www.ruby-forum.com/u/yell13)\
**Post date:** [October 14, 2008, 2:47pm UTC](https://www.ruby-forum.com/t/replace-html-not-working/150875/2 "2008-10-14T14:47:07Z")

</div>

Kiki Kiki wrote:

> hallo, everyone  
> (internal\_server\_error)

hai kiki  
could you post that coding part here ?  
it may be helpful

---

<div class="post-metadata">

**Author:** ![yell13](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ecd19e/32.png) [@yell13](https://www.ruby-forum.com/u/yell13)\
**Post date:** [October 14, 2008, 3:18pm UTC](https://www.ruby-forum.com/t/replace-html-not-working/150875/3 "2008-10-14T15:18:20Z")

</div>

Pokkai D. wrote:

> Kiki Kiki wrote:
> 
> > hallo, everyone  
> > (internal\_server\_error)
> 
> hai kiki  
> could you post that coding part here ?  
> it may be helpful

because i have used moret times replace , and all workde before, don’t  
working now. so i think , maybe only something about environment is  
wrong, maybe. i don’t know.

---

<div class="post-metadata">

**Author:** ![yell13](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ecd19e/32.png) [@yell13](https://www.ruby-forum.com/u/yell13)\
**Post date:** [October 14, 2008, 6:21pm UTC](https://www.ruby-forum.com/t/replace-html-not-working/150875/4 "2008-10-14T18:21:26Z")

</div>

and show in Firebug

# 

ArgumentError

```
in AccountsController#filtered_balances_for_a_month

```

```
tried to create Proc object without a block
```

`RAILS_ROOT: /home/lihui/workspace/adva_cms/adva_cms`

```
<a href="#" 

```

onclick="document.getElementById(‘Framework-Trace’).style.display=‘none’;document.getElementById

(‘Full-Trace’).style.display=‘none’;document.getElementById(‘Application-Trace’).style.display=‘block’

;; return false;"\>Application Trace |

```
<a href="#" 

```

onclick="document.getElementById(‘Application-Trace’).style.display=‘none’;document.getElementById

(‘Full-Trace’).style.display=‘none’;document.getElementById(‘Framework-Trace’).style.display=‘block’

;; return false;"\>Framework Trace |

```
<a href="#" 

```

onclick="document.getElementById(‘Application-Trace’).style.display=‘none’;document.getElementById

(‘Framework-Trace’).style.display=‘none’;document.getElementById(‘Full-Trace’).style.display=‘block’

;; return false;"\>Full Trace

```
<div id="Application-Trace" style="display: block;">
```

---

<div class="post-metadata">

**Author:** ![yell13](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ecd19e/32.png) [@yell13](https://www.ruby-forum.com/u/yell13)\
**Post date:** [October 14, 2008, 3:13pm UTC](https://www.ruby-forum.com/t/replace-html-not-working/150875/5 "2008-10-14T15:13:04Z")

</div>

Pokkai D. wrote:

> Kiki Kiki wrote:
> 
> > hallo, everyone  
> > (internal\_server\_error)
> 
> hai kiki  
> could you post that coding part here ?  
> it may be helpful

1.in View with name :list\_of\_balances.html.erb  
\<% form\_remote\_tag(:url =\>  
filtered\_balances\_for\_a\_month\_admin\_accounts\_path(@chart)) do %\>

please select a month : \<%= date\_select :filter, :month, :order =\> [:month,:year], :add\_month\_numbers =\> true %\> \<%= submit\_tag "Filter balances for a month" %\>

\<% end %\> 
 \<%= render :partial =\> "balances", :locals =\> {:month =\> Date.today,:begin\_date =\> @begin\_date, :end\_date =\> @end\_date}%\>

1. in Views with name : \_balances.html.erb

 \<% for account in @accounts %\> ;"\> 

\<% if account.debit\_sum\_between(begin\_date,end\_date).to\_f \>  
account.credit\_sum\_between(begin\_date,end\_date).to\_f%\>

  
\<% else %\>  
  
  
\<% end %\> \<% end %\>

| \<%=h 'account code'%\> | \<%=h 'account name'%\> | \<%=h 'debit balance'%\> | \<%=h 'credit balance'%\> |
| --- | --- | --- | --- |
| \<%=h account.code%\> | \<%=h account.name%\> | \<%=h account.debit\_sum\_between(begin\_date, end\_date).to\_f -  
account.credit\_sum\_between(begin\_date,end\_date).to\_f %\> | \<%=h ‘0.0’%\> | \<%=h account.credit\_sum\_between(begin\_date, end\_date).to\_f -  
account.debit\_sum\_between(begin\_date,end\_date).to\_f %\> |

1. controller File with name accounts\_controller.rb  
class AccountsController \< ApplicationController  
layout “pac”

before\_filter :find\_chart

def find\_chart  
@chart = Chartofaccount.find(params[:chartofaccount\_id])  
end

def list\_of\_balances  
@accounts = Account.find(:all , :order =\> [‘code ASC’],:conditions  
=\> [‘chartofaccount\_id=?’,@chart])  
date = Date.today  
@begin\_date = date.beginning\_of\_month  
@end\_date = date.end\_of\_month  
end

def filtered\_balances\_for\_a\_month  
@date =  
Date.new(params[:filter][“month(1i)”].to\_i,params[:filter][“month(2i)”].to\_i,1)  
@begin\_date = @date.beginning\_of\_month  
@end\_date = @date.end\_of\_month

```
@accounts = Account.find(:all , :order => ['code ASC'],:conditions 

```

=\> [‘chartofaccount\_id=?’,@chart])

```
# with p @date , i can know ,here working
render :update do |page|
  page.replace_html(:balances, :partial => "balances", :locals => 

```

{:begin\_date =\> @begin\_date, :end\_date =\> @end\_date})  
end  
end  
end

4 routes.rb

# define of ‘admin’ is from colleague

map.connect ‘admin’, :controller =\> ‘admin/sites’,  
:action =\> ‘index’,  
:requirements =\> { :method =\> :get }

# this is from my routes

map.resources :chartofaccounts, :member =\> { :import\_accounts =\> :get  
},  
:controller =\> ‘chartofaccounts’,  
:path\_prefix =\> ‘admin’,  
:name\_prefix =\> ‘admin\_’  
map.resources :accounts, :controller =\> ‘accounts’,  
:path\_prefix =\>  
‘admin/chartofaccounts/:chartofaccount\_id’,  
:name\_prefix =\> ‘admin\_’ ,

```
                       :collection => {:list_of_balances => :get,
                                       :filtered_balances_for_a_month 

```

=\> :post}

if other is helpful , tell me please. and thanks .
