Hi,
I below coded saved in
new.rhtml(C:\RubyForRails\railsapps\phonebook\app\views\phonenumber)
file and executed .
But while accessing getting below issue.
<h1>Add new phonenumber</h1>
<% form_tag '/create' do %>
<p><label for="phonenumber_personname">PersonName</label>:
<%= text_field 'phonenumber', 'personname' %></p>
<p><label for="phonenumber_phnumber">PhoneNumber</label>:
<%= text_field 'phonenumber', 'phnumber' %></p>
<p><label for="phonenumber_typeofnumber">TypeOfPhoneNumber</label>:
<%=
collection_select(:phonenumber,:typeofnumber_id,@names,:id,:typeofnumber)
%></p>
<p><label for="phonenumber_description">Description</label><br/>
<%= text_area 'phonenumber', 'description' %></p>
<%= submit_tag "Create" %>
<% end %>
<%= link_to 'Back', {:action => 'list'} %>
***************************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: <h1>Add new phonenumber</h1>
2: <% form_tag '/create' do %>
3: <p><label for="phonenumber_personname">PersonName</label>:
4: <%= text_field 'phonenumber', 'personname' %></p>
5: <p><label for="phonenumber_phnumber">PhoneNumber</label>:
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'
**************************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
Regards,
GRR
on 2009-11-18 12:57
on 2009-11-18 13:44
Rajeswar reddy Gaulla wrote: > Hi, > > I below coded saved in > new.rhtml(C:\RubyForRails\railsapps\phonebook\app\views\phonenumber) > file and executed . > But while accessing getting below issue. > > <h1>Add new phonenumber</h1> > <% form_tag '/create' do %> > <p><label for="phonenumber_personname">PersonName</label>: > <%= text_field 'phonenumber', 'personname' %></p> > <p><label for="phonenumber_phnumber">PhoneNumber</label>: > <%= text_field 'phonenumber', 'phnumber' %></p> > <p><label for="phonenumber_typeofnumber">TypeOfPhoneNumber</label>: > <%= > collection_select(:phonenumber,:typeofnumber_id,@names,:id,:typeofnumber) > %></p> > <p><label for="phonenumber_description">Description</label><br/> > <%= text_area 'phonenumber', 'description' %></p> > <%= submit_tag "Create" %> > <% end %> > <%= link_to 'Back', {:action => 'list'} %> > > ***************************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: <h1>Add new phonenumber</h1> > 2: <% form_tag '/create' do %> > 3: <p><label for="phonenumber_personname">PersonName</label>: > 4: <%= text_field 'phonenumber', 'personname' %></p> > 5: <p><label for="phonenumber_phnumber">PhoneNumber</label>: > 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' > > > **************************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 > > > Regards, > GRR 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
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.