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' %>
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