ruby on rails 3 - Datamapper Callback for Forum tripcode -


the context: creating tripcode implementation (http://en.wikipedia.org/wiki/tripcode) forum. essentially, weak hash registrationless identification.

there 1 model, 'post'. posts arranged in parent/child format, new post creates parent, replies create child parent. there 1 form, right has field posts controller/model, contains content , password field.

require 'bcrypt' class shout   include datamapper::resource   include bcrypt    property :id, serial                                     # unique key   property :content, text    property :password_hash, string   property :trip, string                                  # trip display        belongs_to :forum   :tree, :order => [:created_at]    attr_accessor :password    #before :save    def password     @password ||= password.new(password_hash)   end    def password=(new_password)     @password = password.create(new_password)     self.password_hash = @password   end    def trip     @trip = '!'<<self.password_hash.to_str[20..33]     self.trip = @trip   end    #end  end  datamapper.finalize 

the basic flow - post/reply, if there password in password field, take , run through bcrypt, store result password_hash later comparison, create tripcode display. i'm getting errors i've been beating head against

the primary error i'm getting is

undefined method `primitive?' nil:nilclass

seemingly emanating

lib/active_support/whiny_nil.rb:48:in `method_missing'

i don't know how handle or work around this. i'm not doing or checking controller, don't yet know what. other error i'm getting stems invalid bcrypt hash, not able duplicate immediately.

the hook methods right off bcrypt-ruby page.

creating bcrypthash field works (dm-types) -- increases time process form factor of 10, on localhost server, , every post need way tweak cost of bcrypt hash (eg. 1 instead of default 10) , run when there password present, why i'm doing this.

but doesn't work right now, i've rammed head against enough , moving on other problems , coming if can input. i'm working rails, i've added tag although not rails issue.

feel free review or contribute or use errors here.

https://github.com/blueblank/shout/tree/oneshout


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -