[Rails] performance question

2011-01-27 Thread klochner
I got sidetracked while benchmarking ruby factorial code: http://rosettacode.org/wiki/Factorial#Ruby I put all that code into test_fact.rb and ran with: > ruby test_fact.rb > rails runner test_fact.rb #from a fresh rails app > rails runner test_fact.rb #from a mature rails app here are the resp

[Rails] metaprogramming, define_method, and class_eval issues

2010-04-08 Thread klochner
I have a 2-part question here that's a little tricky and starting to make my head hurt. I'm working on a plugin for personal use, where I have an rclients table (not named clients because of conflicts with another plugin), and several other models that can have Rclients (polymorphic association).

[Rails] Re: Rails Hosting Questions

2009-06-10 Thread klochner
On Jun 10, 12:02 pm, "Älphä Blüë" wrote: > For those of you using slicehost, can you confirm or add to any of my > notes and/or provide some of your own experiences with setup?  Did you > find it very difficult?  How about porting over sites from another > webhost to slicehost. I started using

[Rails] find_or_create_by_foo_and_bar error (duplicate entry)

2009-04-01 Thread klochner
I'm throwing sql errors on a User.find_or_create_by_foo_and_email call. I created an index with the following: add_index "users", ["foo_id", "email"], :name => "by_foo_email", :unique => true Then in a class foo instance method: user = User.find_or_create_by_foo_id_and_email (self.id,some_email

[Rails] Re: mysql error on scoped find_or_create_by_attr

2009-03-23 Thread klochner
he name 'foobar' exists already? > > On Mar 23, 1:36 pm, klochner wrote: > > > Anyone have insight on this one? > > > class Parent > >   has_many :children > > end > > > add_index "children", ["parent_id", "name"], :

[Rails] mysql error on scoped find_or_create_by_attr

2009-03-23 Thread klochner
Anyone have insight on this one? class Parent has_many :children end add_index "children", ["parent_id", "name"], :name => "by_parent_name", :unique => true a = Parent.find(1) a.children.find_or_create_by_name "foobar" Mysql::Error: Duplicate entry 'foobar' for key 2: INSERT INTO `children`

[Rails] Re: Form doesn't appear in the view.. why?

2009-01-19 Thread klochner
or the following should work, although I'd consider just writing a different partial (_edit_vendor) to render the <% else %> block, and I'd also just duplicate the closing in each block, trading an extra line of code for a self-contained table row. <% unless edit_mode -%> <%= h vendor.nam