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
#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_][email protected][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