search for: recordnotuniqu

Displaying 4 results from an estimated 4 matches for "recordnotuniqu".

Did you mean: recordnotunique
2012 Mar 22
6
rescuing ActiveRecord::RecordNotUnique: clever or ugly?
...self.create_relation(src, dst) where(:src_id => src.id, :dst_id => dst.id).first_or_create! end Which works, but that always does a SELECT before creating the record. Since I don''t expect users to attempt to create duplicates very often, I''ve written a the method to catch RecordNotUnique errors, like this: def self.create_relation(src, dst) create!(:src => src, :dst => dst) rescue ActiveRecord::RecordNotUnique where(:src_id => src.id, :dst_id => dst.id) end So mine is a question of style: is this considered an abuse of rescue? Or is how seasoned Rails programmer...
2012 Apr 03
4
one master table to hold symbols: good or bad idea?
...table :symbols, :force => true do |t| t.string :name end add_index :symbols, :name, :unique=>true class Util::Symbol < ActiveRecord::Base validates :name, :presence => true def self.intern(name) (r = where(:name => name.to_s)).create! rescue ActiveRecord::RecordNotUnique r.first end end ... and using this wherever I''d previously used separate classes. This feels DRYer. Can anyone give a strong argument for or against this approach? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the G...
2012 Oct 24
1
Uniqueness and sql serialize
Hi fellow programmers, I was looking for how to keep integrity in some financial transactions and I saw this "This could even happen if you use transactions with the ‘serializable’ isolation level." in the uniqueness page http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#method-i-validates_uniqueness_of. How this is possible with the serializablo
2012 May 21
1
Active Admin help
I have installed active admin and also add my model -controller rate_professor there.......I can add/delete/edit data using active admin ...but if I click on submit button of my form in rate_professor controller ... I can see whatever I added in the index page ........but I don''t want to see that one.....I want to find the information(whatever I added by clicking submit button) on