search for: activerecorderror

Displaying 18 results from an estimated 18 matches for "activerecorderror".

2004 Oct 16
0
class ActiveRecordError < Exception
Hi, I noticed that ActionControllerError was recently changed in CVS to descend from StandardError instead of Exception, to permit generic rescue clauses to work. Could this be done for ActiveRecordError, also? That issue was a head-scratcher for me the other day when I was porting some code to Active Record. -- Ryan Platte
2008 Mar 19
2
rescue
Hi, whats the correct way to spec a rescue? This will raise it but doesnt test my code''s response # controller def edit @foo = Foo.find(params[:id]) rescue flash[:notice] = "Unknown foo #{params[:id]}" redirect_to foos_path end # spec it "should flash error if not found" do Foo.should_receive(:find).and_raise get :edit, :id
2008 Aug 25
2
to catch exception from update_attribute
...atus_history.problem_id = @problem.id pb_status_history.problem_status_id = @problem.problem_status_id pb_status_history.save! ret_val=@problem.update_attribute("problem_status_id",''ab'') if ret_val==false raise ActiveRecord::ActiveRecordError end end # end of transaction rescue puts ''error is ''+$! end What I was trying to do above was to write a proper exception handling for the above code.In Database table problem_status_id is an integer field And I deliberatly wrote @problem.u...
2006 Mar 06
6
Executing SQL in rails, and the types of the data returned
...gres) return the type boolean. So what''s the deal? And, I don''t like this way of executing SQL. Running find_by_sql on ActiveRecord::Base doesn''t seem to work. At least, it does at first, but when I want to do something with "result", it says: ActiveRecord::ActiveRecordError: ActiveRecord::Base doesn''t belong in a hierarchy descending from ActiveRecord Isn''t there any abstract and clean way of running SQL-queries, that doesn''t have to make use one of your model classes? Thanks in advance -- Posted via http://www.ruby-forum.com/.
2008 Jul 01
6
validates_associated & foreign keys
...s_of :market_id, :scope => :area_code_id end When I create a new area_codes_market record and (deliberately) enter an area_code_id or a market_id that is incorrect, Ruby on Rails doesn''t flag the error. Instead I get an activerecord error on my foreign key constraint. ActiveRecord::ActiveRecordError: Cannot add or update a child row: a foreign key constraint fails (`TestDoneRight_test`.`area_codes_markets`, CONSTRAINT `area_codes_markets_ibfk_2` FOREIGN KEY (`area_code_id`) REFERENCES `area_codes` (`id`)): INSERT INTO `area_codes_markets` (`area_code_id`, `market_id`) VALUES(2, 1) Reading the...
2006 Mar 28
12
cached-model broken with Rails 1.1
It looks like cached-model is broken again under rails 1.1. Can anyone confirm? Note that the exception below indicates it''s trying to treat CachedModel as the class name of the model, rather than using the proper class name (which is Entry in this case, and the table called entries). This is a model using Single Table Inheritance and acts_as_tree, and worked just fine under 1.0 and
2007 Aug 23
6
controller spec with model that validates_uniqueness
I want to use mocks and stubs to test the controller, but am having trouble getting my validation not to trigger. Here''s the code: # spec: Image.stub!(:find).and_return(@image) @image.should_receive(:save!).once.with(:any_args) put :update, :id => @image.id, :category_id => @category.id, :image => {:name => ''test'', :image_number =>
2006 May 06
1
Rails Project only with root rights
...v and gem -v does work only with root rights. On the command: developer@linux:~/data> rails test I get following output: /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:95:in `const_missing'': undefined method `demodulize'' for "ActiveRecordError":String (NoMethodError) from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/validations.rb:9 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3....
2006 Apr 04
0
rails Test problem
...and gem installed rails, no problem. However, when I try and set up a test app a get the following error: ~> rails Test /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:84:in `const_missing'': undefined method `demodulize'' for "ActiveRecordError":String (NoMethodError) from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/validations.rb:9 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3...
2005 Dec 16
1
Exception Locations?
I am trying to locate the following in the current 1.0 source tree: ActiveRecord::RecordNotFound ActionController::UnknownAction Looking at the API docs, I''ve been unable to track these down. Can someone help?
2006 Jan 20
3
Dispatcher Issues
Should I be able to run this and get some meaningful output? I''m trying to convert my app to run with Apache2/CGI and I''ve got the snippet that the RoR book suggests. The app runs fine with WEBrick, but I''ve got to scale it a little bit. [root@ops cms]# ruby public/dispatch.fcgi
2010 Sep 27
0
problem with set_sequence_name please help
..."COURT_SEQ" which look ok. When AdCourt.create!(:caption => ''AAAA'', :code => ''1111'', :version => 0, :created_by_id => 0) it''s still using "ad_courts_seq" which not exist. ActiveRecord::StatementInvalid: ActiveRecord::ActiveRecordError: ORA-02289: sequence does not exist : select ad_courts_seq.nextval id from dual from /Users/cyberjom/.rvm/gems/jruby-1.5.2/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:202:in `log'' from /Users/cyberjom/.rvm/gems/jruby-1.5.2/gems/activerecord-jdbc-ad...
2006 Mar 23
2
rails 1.1 and mysql errors
...gt; :memberships ............. class Membership < ActiveRecord::Base belongs_to :user has_and_belongs_to_many :roles ............ class Role < ActiveRecord::Base has_and_belongs_to_many :memberships ............. test_reference_roles_through_membership(UserTest): ActiveRecord::ActiveRecordError: Invalid source reflection macro :has_and_belongs_to_many for has_many roles, :through => memberships c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2.4008/lib/active_record/associations/has_many_through_association.rb:75:in `construct_conditions '' Rails 1.1 does not fix the exi...
2005 Aug 10
5
validates_format_of on an optional field using :if
Hi there, I''ve got the following in my model: validates_format_of :postcode, :with => /^([a-zA-Z]{1,2}[0-9]{1,2} [0-9]{1}[a-zA-Z]{2})$/, :message => "is not valid", :if => :postcode ... but it''s not working - it always insists on validation, even if postcode is empty. Basically, the postcode field is optional, but if it''s filled in, I want to
2006 Aug 06
0
Rails Core Weekly July 16 - August 6
...on.name}.blank? raise DestroyRestricted.new(self, #{reflection.name.inspect}) end end alias_method_chain :destroy, "has_many_#{reflection.name}" end_eval # ... end base.rb module ActiveRecord class DestroyRestricted < ActiveRecordError def initialize(model, by) super "#{model.class.name} #{model.id} destroy restricted by #{by}" end end end [thread: http://www.ruby-forum.com/topic/75349#new ] Courtnay runs Rails with ruby 1.8.5 and comes across several issues which he of course patches. A...
2010 Dec 14
4
Change primary_key column name
Hi, after changing a primary key column name, the auto-increment information (MySQL) and sequence (Oracle) are lost. What is the correct way to rename primary keys? Thanks, Gustavo -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to
2010 Jan 03
24
SQLServer on Rails
Does any one know how to setup SQLserver with ruby1.9. It was working on an earlier version and now nothing works! I have installed the gems dbi ,dbd-odbc and activerecord-odbc-adapter and can connect in straight Ruby. However, using rails with database.yml nothing works! I hosed everything and reinstalled rails and now, I get Win32/Parite virus on ruby.exe. Any ideas? I''m losing
2006 Jul 24
7
[PATCH] Support for DB Clusters/Replication in ActiveRecord (RFC)
...compatibility. + id = round_robin_write_connection.object_id + when :read + id = round_robin_read_connection.object_id + else + # If someone passes garbage, raise error. + # they could have misspelt "read" and that could bork their database. + raise ActiveRecordError, "Connection type can only be read or write." + end + if conn = active_connections[id] conn else # retrieve_connection sets the cache key. - conn = retrieve_connection - active_connections[@active_connection_name] = conn +...