Please help --> Getting error ERROR NoMethodError: private method `gsub!' called for #<Class:0x47a8

[2010-07-21 11:35:18] ERROR NoMethodError: private method gsub!' called for #<Class:0x47a8e38> C:/Applns/Ruby187/lib/ruby/1.8/webrick/htmlutils.rb:16:inescape’
C:/Applns/Ruby187/lib/ruby/1.8/webrick/httpresponse.rb:232:in
set_error' C:/Applns/Ruby187/lib/ruby/gems/1.8/gems/rails-2.2.3/lib/ webrick_server.rb:94:inhandle_file’
C:/Applns/Ruby187/lib/ruby/gems/1.8/gems/rails-2.2.3/lib/
webrick_server.rb:73:in service' C:/Applns/Ruby187/lib/ruby/1.8/webrick/httpserver.rb:104:inservice’
C:/Applns/Ruby187/lib/ruby/1.8/webrick/httpserver.rb:65:in
run' C:/Applns/Ruby187/lib/ruby/1.8/webrick/server.rb:173:instart_thread’
C:/Applns/Ruby187/lib/ruby/1.8/webrick/server.rb:162:in
start' C:/Applns/Ruby187/lib/ruby/1.8/webrick/server.rb:162:instart_thread’
C:/Applns/Ruby187/lib/ruby/1.8/webrick/server.rb:95:in start' C:/Applns/Ruby187/lib/ruby/1.8/webrick/server.rb:92:ineach’
C:/Applns/Ruby187/lib/ruby/1.8/webrick/server.rb:92:in start' C:/Applns/Ruby187/lib/ruby/1.8/webrick/server.rb:23:instart’
C:/Applns/Ruby187/lib/ruby/1.8/webrick/server.rb:82:in start' C:/Applns/Ruby187/lib/ruby/gems/1.8/gems/rails-2.2.3/lib/ webrick_server.rb:60:indispatch’
C:/Applns/Ruby187/lib/ruby/gems/1.8/gems/rails-2.2.3/lib/
commands/servers/webrick.rb:66
C:/Applns/Ruby187/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:31:in gem_original_require' C:/Applns/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:31:inrequire’
C:/Applns/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.2.3/
lib/active_support/dependencies.rb:153:in
require' C:/Applns/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.2.3/ lib/active_support/dependencies.rb:521:innew_constants_in’
C:/Applns/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.2.3/
lib/active_support/dependencies.rb:153:in
require' C:/Applns/Ruby187/lib/ruby/gems/1.8/gems/rails-2.2.3/lib/ commands/server.rb:49 C:/Applns/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:31:ingem_original_require’
C:/Applns/Ruby187/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:31:in `require’
script/server:3
127.0.0.1 - - [21/Jul/2010:11:35:18 India Standard Time] “GET / HTTP/
1.1” 500 338

Just try to “http://localhost:3000/” after starting the webrick server.

:frowning:

sorry i don’t think these lines given below are help full to find out
error
run “ruby script/server -t”
Goto Yours development log file copy all the text and paste all text
of that file here


Thanks:
Rajeev sharma

I got invalid option for “-t”

Please check below

ruby script/server -t
=> Booting WEBrick…
server: invalid option: -t
=> Rails 2.2.3 application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2010-07-21 12:43:28] INFO WEBrick 1.3.1
[2010-07-21 12:43:28] INFO ruby 1.8.7 (2010-01-10) [i386-mingw32]
[2010-07-21 12:43:28] INFO WEBrick::HTTPServer#start: pid=2720
port=3000

One more point like I have tried to configure my DB in database.yml.

It was

development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

I changed to

development:
adapter: mysql
database: library_development
username: root
password: *****
host: localhost
pool: 5
timeout: 5000

Any problem with this ?

Write the code here pleZse

On Wed, Jul 21, 2010 at 12:09 PM, Sony T. [email protected]
wrote:

   C:/Applns/Ruby187/lib/ruby/1.8/webrick/httpserver.rb:104:in
   C:/Applns/Ruby187/lib/ruby/1.8/webrick/server.rb:92:in `each'

custom_require.rb:31:in `require’
commands/server.rb:49
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


Thanks:
Rajeev sharma

S

:slight_smile:

use instant rails if possible go back on ruby on rails installation
again

On Wed, Jul 21, 2010 at 2:27 PM, [email protected] wrote:

Subject: Re: [Rails] Please help → Getting error ERROR NoMethodError: private method `gsub!’ called for #Class:0x47a8e38

database: db/development.sqlite3
host: localhost
Subject: Re: [Rails] Please help → Getting error ERROR NoMethodError:
Thanks:


You received this message because you are subscribed to the Google G. “Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


Thanks:
Rajeev sharma

its yours first application on rails ?

On Wed, Jul 21, 2010 at 1:01 PM, [email protected] wrote:

I changed to
Any problem with this ?
error
You received this message because you are subscribed to the Google
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


Thanks:
Rajeev sharma

I am working with railspace social networking application. I did login
logout registration process in it but as i am introducing the concept
for remember me then stuck in the problem. it is showing the following
error.

private method `gsub’ called for 4:Fixnum

C:/Users/Amir/Downloads/IR/ruby/lib/ruby/1.8/cgi.rb:342:in escape' C:/Users/Amir/Downloads/IR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/cgi_ext/cookie.rb:73:into_s’
C:/Users/Amir/Downloads/IR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/cgi_ext/cookie.rb:73:in
collect' C:/Users/Amir/Downloads/IR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/cgi_ext/cookie.rb:73:into_s’
C:/Users/Amir/Downloads/IR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/cookies.rb:80:in
set_cookie' C:/Users/Amir/Downloads/IR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/cookies.rb:65:in[]=’
app/controllers/user_controller.rb:27:in `login’

Please help me out. Any help is appreciated

Thanks

Amir

On 25 April 2012 08:13, Amir Z. [email protected] wrote:

C:/Users/Amir/Downloads/IR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/cgi_ext/cookie.rb:73:in

`collect’

C:/Users/Amir/Downloads/IR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/cgi_ext/cookie.rb:73:in

`to_s’

C:/Users/Amir/Downloads/IR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/cookies.rb:80:in

`set_cookie’

C:/Users/Amir/Downloads/IR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/cookies.rb:65:in

[]=' app/controllers/user_controller.rb:27:in login’

It is telling you the line that the problem is (line 27 in
user_controller.rb, which is a bit odd, I would have expected it to be
called users_controller.rb not user_controller.rb), and the error
tells you that you are calling gsub, but the object you are calling it
on is a number instead of a valid object that understands the method
gsub. Have a look at that line. Then if you cannot see the problem
have a look at the Rails Guide on debugging for suggestions on how to
debug your code.

Colin

Thanks Colin
we are calling it as an object. Please find my login code below.

def login
if request.get?
@user = User.new(:remember_me => cookies[:remember_me] || “0”)
elsif param_posted?(:user)
@user = User.new(params[:user])
user = User.find_by_screen_name_and_password(@user.screen_name,
@user.password)
if user
user.login!(session)
if @user.remember_me == “1”
cookies[:remember_me] = { :value => “1”,
:expires => 10.years.from_now }
user.authorization_token = user.id
user.save!
cookies[:authorization_token] = { (line no. 27)
:value => user.authorization_token, (line no. 28)
:expires => 10.years.from_now } (line no. 29)
else
cookies.delete(:remember_me)
cookies.delete(:authorization_token)
end
flash[:notice] = “User #{user.screen_name} logged in!”
redirect_to_forwarding_url
else
@user.clear_password!
flash[:notice] = “Invalid screen name/password combination”
end
end
end

Error showing in line no. 27

Please find below the error trace

C:/Users/Amir/Downloads/IR/ruby/lib/ruby/1.8/cgi.rb:342:in escape' C:/Users/Amir/Downloads/IR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/cgi_ext/cookie.rb:73:into_s’
C:/Users/Amir/Downloads/IR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/cgi_ext/cookie.rb:73:in
collect' C:/Users/Amir/Downloads/IR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/cgi_ext/cookie.rb:73:into_s’
C:/Users/Amir/Downloads/IR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/cookies.rb:80:in
set_cookie' C:/Users/Amir/Downloads/IR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/cookies.rb:65:in[]=’
app/controllers/user_controller.rb:27:in `login’

On 25 April 2012 08:53, Amir Z. [email protected] wrote:

Thanks Colin
we are calling it as an object. Please find my login code below.

Which is the line generating the error?

Colin

On Wednesday, 25 April 2012 03:53:59 UTC-4, Ruby-Forum.com User wrote:

@user.password)
if user
user.login!(session)
if @user.remember_me == “1”
cookies[:remember_me] = { :value => “1”,
:expires => 10.years.from_now }
user.authorization_token = user.id

This is where things go wrong - user.id is not a string.

user.save!
cookies[:authorization_token] = { (line no. 27)
:value => user.authorization_token, (line no. 28)

The cookie value here must be a string - passing in a Fixnum is what’s
causing the error. The original RailsSpace code sets the token to a
hashed
string, not the user’s id.

Regarding RailsSpace: that book is wildly out-of-date (I note that
you’re
using Rails 2.0.2 from the traces above) and does some things that were
extremely questionable even for that time period. For instance, storing
passwords in cleartext in the DB is strongly discouraged - it’s led to
massive security breaches over the years on other web applications.

Here’s an updated tutorial from the RailsSpace authors, so you’re not
learning the 2007 version of the framework:

–Matt J.