Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !!Cannot/Will not remove some constant. If nothing else, it's really annoying to see it in my server window/log file.
- Also, complains about User not having a password method in my form that calls something to the effect of
- <%= password_field 'user', 'password' %>
- I believe it is related to this constant thing as it works once I restart the server (mongrel)
- ## application trace [plaintext]
- Wed Jun 06 15:17:43 -0400 2007: Error calling Dispatcher.dispatch #<NameError: cannot remove Object::Base>
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:423:in `remove_const'
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:423:in `send'
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:423:in `remove_constant'
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:274:in `remove_unloadable_constants!'
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:274:in `each'
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:274:in `remove_unloadable_constants!'
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:73:in `clear'
- /var/lib/gems/1.8/gems/rails-1.2.1/lib/dispatcher.rb:60:in `reset_application!'
- /var/lib/gems/1.8/gems/rails-1.2.1/lib/dispatcher.rb:116:in `reset_after_dispatch'
- /var/lib/gems/1.8/gems/rails-1.2.1/lib/dispatcher.rb:51:in `dispatch'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/rails.rb:84:in `process'
- /usr/lib/ruby/1.8/sync.rb:229:in `synchronize'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/rails.rb:83:in `process'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:580:in `process_client'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:579:in `each'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:579:in `process_client'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:686:in `run'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:686:in `initialize'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:686:in `new'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:686:in `run'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:673:in `initialize'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:673:in `new'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:673:in `run'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/configurator.rb:267:in `run'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/configurator.rb:266:in `each'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/configurator.rb:266:in `run'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/bin/mongrel_rails:127:in `run'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/command.rb:211:in `run'
- /var/lib/gems/1.8/gems/mongrel-0.3.13.4/bin/mongrel_rails:231
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:489:in `load'
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:489:in `load'
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:343:in `new_constants_in'
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:489:in `load'
- /var/lib/gems/1.8/gems/rails-1.2.1/lib/commands/servers/mongrel.rb:60
- /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
- /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require'
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:496:in `require'
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:343:in `new_constants_in'
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:496:in `require'
- /var/lib/gems/1.8/gems/rails-1.2.1/lib/commands/server.rb:39
- /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
- /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require'
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:496:in `require'
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:343:in `new_constants_in'
- /var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:496:in `require'
- script/server:3
- ## What happens when I try to stop the server [plaintext]
- ** INT signal received.
- Wed Jun 06 15:32:33 -0400 2007: Reaping 1 threads for slow workers because of 'shutdown'
- Waiting for 1 requests to finish, could take 60 seconds.
- !!I then force it to close (ctrl-C)
- ## RegisterController.rb (associated method(s) only) [ruby]
- include RegisterHelper
- class RegisterController < ApplicationController
- def index
- list
- redirect_to :action => 'new'
- end
- ...
- def new
- @user = User.new
- session[:verification_count] ||= 0
- answer = []
- answer = generate_validation_image
- session[:verification_string] = answer[0]
- @image = answer[1].to_s
- end
- ...
- end
- ## register_helper.rb [ruby]
- require 'digest/sha1'
- require 'RMagick'
- include Magick
- include RandomHelper
- module RegisterHelper
- Select_Colors = ['red', 'blue', 'yellow', 'orange', 'purple', 'green', 'white']
- Select_Rotation = (-75..75).to_a
- # Size = { :x => (10..90).to_a, :y => (50..100).to_a }
- Select_Points = [20, 24, 28, 32, 36, 42, 48, 52]
- # Fonts = ['Tahoma', 'Lucida Console', 'Lucida Sans', 'Verdana', 'Times New Roman', 'Purisa']
- Select_Fonts = ['helvetica', 'courier', 'arial', 'garamond', 'verdana']
- def generate_validation_image
- file_name = random_hash(10).to_s
- verisign = Image.new(500, 100) do |image|
- image.background_color = Select_Colors[rand(7)]
- end
- letters = ""
- -1.upto(3) do |i|
- text = Draw.new
- point = Select_Points[rand(8)]
- point_offset = (0.8 * point).to_i
- #size = {}
- #size[:x] = Size[:x][rand(Size[:x].length)]
- #size[:y] = Size[:y][rand(Size[:y].length)]
- location = {}
- location[:x] = (((i+1)*100 + point_offset)..((i+2)*100 - point_offset)).to_a
- # print "\n" + size[:x].to_s
- location[:y] = ((1 + point_offset)...(100 - point_offset)).to_a
- location[:x] = location[:x][rand(location[:x].length)]
- location[:y] = location[:y][rand(location[:y].length)]
- rotation = Select_Rotation[rand(Select_Rotation.length)]
- #text.rotate(rotation)
- print "r" + rotation.to_s + "\n"
- letter = A_to_z[rand(48)]
- letters << letter
- # print "\n(" + size[:x].to_s + "," + size[:y].to_s + "," + location[:x].to_s + "," + location[:y].to_s + "," + letter + ")\n"
- #text.annotate(verisign, size[:x], size[:y], location[:x], location[:y], letter) {
- text.annotate(verisign, 0,0, location[:x], location[:y], letter) {
- self.rotation = rotation
- self.pointsize = point
- self.gravity = NorthWestGravity
- text.font_family = Select_Fonts[rand(5)]
- }
- #text.annotate(verisign, size[:x], size[:y], location[:x], location[:y], letter)
- #text.rotation = rotation_angle
- #text.gravity = ForgetGravity
- #text.pointsize = 20
- end
- text = Draw.new
- verisign.write(RAILS_ROOT.to_s + "/public/images/" + file_name + '.png')
- return [letters, file_name]
- end
- end
- ## random_helper.rb [ruby]
- require 'digest/sha1'
- include Digest
- module RandomHelper
- A_to_z = (('A'..'Z').to_a << ('a'..'z').to_a).flatten
- Select_Words = ['wibble', 'death', 'kill', 'murder', 'steal']
- def random_hash(randomization)
- hash_string = ''
- case randomization
- when 5
- 2.times do
- hash_string << A_to_z[rand(48)] + (0..5).to_a[rand(6)].to_s + (0..100).to_a[rand(100)].to_s + A_to_z[rand(48)]
- end
- ...
- end
- hash_string << Select_Words[rand(5)]
- hash_string << Time.now.to_s
- hash_string = SHA1.hexdigest(hash_string)
- end
- end
- ## user.rb [ruby]
- require 'digest/sha1'
- class User < ActiveRecord::Base
- has_many :comments
- has_and_belongs_to_many :masks
- validates_presence_of :human_name
- ...
- attr_accessor :password_confirmation
- def validate
- errors.add_to_base("Missing password") if hashed_password.blank?
- end
- def password
- @password
- end
- def password=(pwd)
- @password = pwd
- create_new_salt
- self.hashed_password = User.encrypted_password(self.password, self.salt)
- end
- end
Add Comment
Please, Sign In to add comment