# Need info on form\_tag

**URL:** <https://www.ruby-forum.com/t/need-info-on-form-tag/179147>\
**Category:** Rails\
**Created:** [November 18, 2009, 1:05pm UTC](https://www.ruby-forum.com/t/need-info-on-form-tag/179147 "2009-11-18T13:05:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rajeswar\_reddy\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@Rajeswar\_reddy\_G](https://www.ruby-forum.com/u/Rajeswar_reddy_G)\
**Post date:** [November 18, 2009, 1:05pm UTC](https://www.ruby-forum.com/t/need-info-on-form-tag/179147/1 "2009-11-18T13:05:11Z")

</div>

Hi,

I below coded saved in  
new.rhtml(C:\RubyForRails\railsapps\phonebook\app\views\phonenumber)  
file and executed .  
But while accessing getting below issue.

\*\*\*\*\*\*\*\*\*\*\*\*\*\* new.rhtml code\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

# Add new phonenumber
\<% form\_tag '/create' do %\> 

PersonName: \<%= text\_field 'phonenumber', 'personname' %\>

PhoneNumber: \<%= text\_field 'phonenumber', 'phnumber' %\>

TypeOfPhoneNumber: \<%= collection\_select(:phonenumber,:typeofnumber\_id,@names,:id,:typeofnumber) %\>

Description  
 \<%= text\_area 'phonenumber', 'description' %\>

 \<%= submit\_tag "Create" %\> \<% end %\> \<%= link\_to 'Back', {:action =\> 'list'} %\>

**phonenumber\_controller.rb code** \*  
class PhonenumberController \< ApplicationController  
def list  
@phonenumbers = Phonenumber.find(:all)  
end

def new  
@Phonenumber = Phonenumber.new  
@names = Name.find(:all)  
end

def create  
@phonenumber = Phonenumber.new(params[:phonenumber])  
if @phonenumber.save  
redirect\_to :action =\> ‘list’  
else  
@names = Name.find(:all)  
render :action =\> ‘new’  
end  
end

end

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*Error \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

NoMethodError in Phonenumber#new

Showing app/views/phonenumber/new.rhtml where line #2 raised:

undefined method `^’ for “5”:String  
Extracted source (around line #2):

1:

# Add new phonenumber
  
2: \<% form\_tag ‘/create’ do %\>  
3: 

PersonName:  
4: \<%= text\_field ‘phonenumber’, ‘personname’ %\>

  
5: 

PhoneNumber:  
RAILS\_ROOT: C:/RubyForRails/railsapps/phonebook

Application Trace | Framework Trace | Full Trace  
C:/RubyForRails/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active\_support/message\_verifier.rb:46:in  
`block in secure_compare' C:/RubyForRails/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/message_verifier.rb:45:in`each’  
C:/RubyForRails/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active\_support/message\_verifier.rb:45:in  
`secure_compare' C:/RubyForRails/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/message_verifier.rb:28:in`verify’  
C:/RubyForRails/lib/ruby/gems/1.9.1/gems/actionpack-2.3.4/lib/action\_controller/session/cookie\_store.rb:156:in  
`unmarshal' C:/RubyForRails/lib/ruby/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/session/cookie_store.rb:145:in`load\_session’  
C:/RubyForRails/lib/ruby/gems/1.9.1/gems/actionpack-2.3.4/lib/action\_controller/session/abstract\_store.rb:62:in  
`block in load!' C:/RubyForRails/lib/ruby/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/session/abstract_store.rb:70:in`stale\_session\_check!’  
C:/RubyForRails/lib/ruby/gems/1.9.1/gems/actionpack-2.3.4/lib/action\_controller/session/abstract\_store.rb:61:in  
`load!' C:/RubyForRails/lib/ruby/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/session/abstract_store.rb:28:in`[]’  
C:/RubyForRails/lib/ruby/gems/1.9.1/gems/actionpack-2.3.4/lib/action\_controller/request\_forgery\_protection.rb:102:in  
`form_authenticity_token' (eval):2:in`form\_authenticity\_token’  
C:/RubyForRails/railsapps/phonebook/app/views/phonenumber/new.rhtml:2:in  
`\_run\_rhtml\_app47views47phonenumber47new46rhtml’

Regards,  
GRR

---

<div class="post-metadata">

**Author:** ![Rajeswar\_reddy\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@Rajeswar\_reddy\_G](https://www.ruby-forum.com/u/Rajeswar_reddy_G)\
**Post date:** [November 18, 2009, 1:45pm UTC](https://www.ruby-forum.com/t/need-info-on-form-tag/179147/2 "2009-11-18T13:45:47Z")

</div>

Hi,

I found the root cause to this issue.

it occurring because of secure\_compare method in  
lib\ruby\gems\1.9.1\gems\activesupport-2.3.4\lib\active\_support\message\_verifier.rb

existing method in 2.3.4

```
  def secure_compare(a, b)
    if a.length == b.length
      result = 0
      for i in 0..(a.length - 1)
        result |= a[i] ^ b[i]
      end
      result == 0
    else
      false
    end
  end

```

to come out of this issue use below method, if you want.

```
  def secure_compare(a, b)
    result = a.length ^ b.length
    for i in 0..99 # or some other constant
      result |= a[i].to_i ^ b[i].to_i
    end
    result == 0
  end

```

to know about issue, please visit:  
[https://rails.lighthouseapp.com/projects/8994/tickets/3144-undefined-method-for-string-ror-234](https://rails.lighthouseapp.com/projects/8994/tickets/3144-undefined-method-for-string-ror-234)
