# Wacky View errors

**URL:** <https://www.ruby-forum.com/t/wacky-view-errors/139463>\
**Category:** Rails\
**Created:** [June 4, 2008, 2:33am UTC](https://www.ruby-forum.com/t/wacky-view-errors/139463 "2008-06-04T02:33:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![taro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df705f/32.png) [@taro](https://www.ruby-forum.com/u/taro)\
**Post date:** [June 4, 2008, 2:33am UTC](https://www.ruby-forum.com/t/wacky-view-errors/139463/1 "2008-06-04T02:33:47Z")

</div>

I have what seems to be internal errors in my views, according to my  
functional tests:

* * *

test\_no\_param\_edit\_member(MemberListControllerTest):  
ActionView::TemplateError: undefined method `merge’ for “First  
name”:String  
On line #6 of member\_list/edit\_member.rhtml

```
3: </h1>
4: <div id="edit">
5: <% form_for :person do |form| %>
6: <%= form.label :person, :first_name, 'First name' %>
7: <%= form.text_field :first_name, :size => 30 %>
8: <%= form.label :person, :last_name, 'Last name' %>
9: <%= form.text_field :last_name, :size => 30 %>

c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/

```

## helpers/form\_helper.rb:660:in `label' app/views/member_list/edit_member.rhtml:6:in`\_run\_erb\_47app47views47member\_list47edit\_member46rhtml’ c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_view/ helpers/form\_helper.rb:248:in `fields_for' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ helpers/form_helper.rb:184:in`form\_for’ app/views/member\_list/edit\_member.rhtml:5:in `_run_erb_47app47views47member_list47edit_member46rhtml' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ base.rb:637:in`send’ c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_view/ base.rb:637:in `compile_and_render_template' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ base.rb:365:in`render\_template’ c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_view/ base.rb:316:in `render_file' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:1100:in`render\_for\_file’ c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action\_controller/base.rb:858:in `render_with_no_layout' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:872:in`render\_with\_no\_layout’ c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action\_controller/layout.rb:262:in `render_without_benchmark' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/benchmarking.rb:51:in`render’ c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/benchmarking.rb:51:in`render’ app/controllers/member\_list\_controller.rb:20:in `edit_member' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:1158:in`send’ c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action\_controller/base.rb:1158:in `perform_action_without_filters' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/filters.rb:697:in`call\_filters’ c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action\_controller/filters.rb:689:in `perform_action_without_benchmark' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/benchmarking.rb:68:in`perform\_action\_without\_rescue’ c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/benchmarking.rb:68:in`perform\_action\_without\_rescue’ c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action\_controller/rescue.rb:199:in `perform_action_without_caching' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/caching.rb:678:in`perform\_action’ c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2-/lib/ active\_record/connection\_adapters/abstract/query\_cache.rb:33:in `cache' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2-/lib/ active_record/query_cache.rb:8:in`cache’ c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action\_controller/caching.rb:677:in `perform_action' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:524:in`send’ c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action\_controller/base.rb:524:in `process_without_filters' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/filters.rb:685:in`process\_without\_session\_management\_support’ c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action\_controller/session\_management.rb:123:in `process_without_test' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/test_process.rb:15:in`process’ c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action\_controller/test\_process.rb:393:in `process' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/test_process.rb:364:in`post’ member\_list\_controller\_test.rb:203:in `test_no_param_edit_member' c:/ruby/lib/ruby/1.8/test/unit/testcase.rb:78:in` **send** ’ c:/ruby/lib/ruby/1.8/test/unit/testcase.rb:78:in `run' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2-/lib/ active_support/testing/default.rb:7:in`run’ c:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' c:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in`each’ c:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' c:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:34:in`run’ c:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' c:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in`run’ c:/ruby/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in `run_suite' c:/ruby/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:67:in`start\_mediator’ c:/ruby/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:41:in `start' c:/ruby/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:in`run’ c:/ruby/lib/ruby/1.8/test/unit/autorunner.rb:216:in `run' c:/ruby/lib/ruby/1.8/test/unit/autorunner.rb:12:in`run’ c:/ruby/lib/ruby/1.8/test/unit.rb:278 member\_list\_controller\_test.rb:202

What does this mean? Does it have to do with InstantRails, which I am  
using?

## By the way, here’s the code that I wrote:

# Edit

 \<% form\_for :person do |form| %\> \<%= form.label :person, :first\_name, 'First name' %\> \<%= form.text\_field :first\_name, :size =\> 30 %\> \<%= form.label :person, :last\_name, 'Last name' %\> \<%= form.text\_field :last\_name, :size =\> 30 %\> \<%= form.label :person, :rin, 'Rensselaer ID' %\> \<%= form.text\_field :rin, :size =\> 10 %\> \<%= form.label :person, :email %\> \<%= form.text\_field :email, :size =\> 30 %\> \<%= form.label :person, :year, 'Graduation Year' %\> \<%= form.select( :year, generate\_year\_array( @person.year ) ) %\> \<%= submit\_tag "Edit!" %\> \<%end%\>
------- ###-----test edit member-----#### def test\_valid\_edit\_member person = Person.find(1) assert\_equal person.first\_name, 'Tommy' assert\_equal person.last\_name, 'Nook' assert\_equal person.rin, 'nookt' assert\_equal person.email, 'removed\_email\_address@domain.invalid' post :edit\_member, { :id =\> 1, :lang\_url\_id =\> 'en', :person =\> { :first\_name =\> 'Jam', :last\_name =\> 'Ojisan', :rin =\> 'ojisaj', :email =\> 'removed\_email\_address@domain.invalid' } }, { :user\_id =\> 5 } assert\_response :redirect assert\_redirected\_to :controller =\> 'member\_list', :action =\> 'list\_members', :lang\_url\_id =\> 'en', :id =\> 0 person = Person.find(1) assert\_equal person.first\_name, 'Jam' assert\_equal person.last\_name, 'Ojisan' assert\_equal person.rin, 'ojisaj' assert\_equal person.email, 'removed\_email\_address@domain.invalid' end ----- ######Controller class MemberListController \< ApplicationController layout "member\_list"

#use this to sign up, list all members, and delete members  
#also for turning members to officer, admin, member,  
#and changing passwords  
before\_filter :admin?,  
:except =\> [:list\_members, :update\_password, :return\_to\_listing]  
before\_filter :officer?,  
:only =\> [:list\_members, :update\_password]

verify :method =\> :post, :except =\> [:list\_members],  
:redirect\_to =\> { :controller =\> ‘view’, :action =\> ‘view’,  
:lang\_url\_id =\> ‘en’, :wiki\_id =\> 1 }

#edit any member, including yourself  
def edit\_member  
@person = Person.find( params[:id] )  
if !params[:person]  
render :action =\> ‘edit\_member’  
elsif @person.update\_attributes( params[:person] )  
return\_to\_listing #a private method that redirects to listing.  
else  
render :action =\> ‘edit\_member’  
end  
end

# There’s more to this, but it will take up too much space

## end

#######Model  
class Person \< ActiveRecord::Base  
#first\_name is required: must start with a capital  
validates\_presence\_of :first\_name  
validates\_format\_of :first\_name,  
:with =\> /^[A-Z][a-zA-Z0-9, .]+$/

#last\_name is required: must start with a capital  
validates\_presence\_of :last\_name  
validates\_format\_of :last\_name,  
:with =\> /^[A-Z][a-zA-Z0-9, .]+$/

#rin is required: must be unique; also, must all be lowercases  
#with 0 to 2 numbers following the letters.  
validates\_presence\_of :rin  
validates\_format\_of :rin,  
:with =\> /^[a-z]+[0-9]{0,2}$/  
validates\_uniqueness\_of :rin

#email must be unique, and it is required.  
validates\_presence\_of :email  
validates\_format\_of :email,  
:with =\> /^[a-zA-Z0-9\_]+@[a-zA-Z0-9\_]+(.[a-z]{2,3}){1,2}$/  
validates\_uniqueness\_of :email

#year is required, and must be a 4 digit number greater than 2000  
validates\_presence\_of :year  
validates\_numericality\_of :year,  
:only\_integer =\> true  
validates\_length\_of :year,  
:is =\> 4  
end

---

<div class="post-metadata">

**Author:** ![taro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df705f/32.png) [@taro](https://www.ruby-forum.com/u/taro)\
**Post date:** [June 4, 2008, 2:38am UTC](https://www.ruby-forum.com/t/wacky-view-errors/139463/2 "2008-06-04T02:38:28Z")

</div>

My mistake, this is the test that was giving me this error:

* * *

def test\_no\_param\_edit\_member  
post :edit\_member, { :id =\> 1,  
:lang\_url\_id =\> ‘en’ },  
{ :user\_id =\> 5 }  
assert\_response :success  
assert\_template ‘member\_list/edit\_member’  
assert\_no\_nil assigns[‘person’]  
assert\_equal assigns[‘person’].first\_name, ‘Tommy’  
assert\_equal assigns[‘person’].last\_name, ‘Nook’  
assert\_equal assigns[‘person’].rin, ‘nookt’  
assert\_equal assigns[‘person’].email, ‘removed\_email\_address@domain.invalid’  
end

---

<div class="post-metadata">

**Author:** ![taro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df705f/32.png) [@taro](https://www.ruby-forum.com/u/taro)\
**Post date:** [June 4, 2008, 2:41am UTC](https://www.ruby-forum.com/t/wacky-view-errors/139463/3 "2008-06-04T02:41:59Z")

</div>

Nevermind, I forgot that Google is my friend =P
