similar to: Shortcircuit evaluations

Displaying 20 results from an estimated 2000 matches similar to: "Shortcircuit evaluations"

2006 Jun 20
2
Problem with "can''t dump anonymous class Class"
I submitted this earlier, but the web forums went down and I''ve screwed up the thread, so I''m starting over. I''m trying to built a document upload system. The system has a main Document model with different subclasses for different types of documents. With the code below, if I attempt to create a Document, it works fine, but if I attempt to use one of the subclasses, I
2005 May 04
1
Conditional validations
I''ve been working with the problem that Joe Hosteny has been talking about on this list and on the tickets he''s posted (http://dev.rubyonrails.com/ticket/1196) and have come up with a tentative solution that I''d like to bring up here. What if we use a "conditional" parameter in the validates_* methods? Here''s how it would look like in practice:
2006 Feb 17
1
validate() with has_many association
I''m creating a simple portfolio site for a painter. I have a painting and an image model with following relationship: Painting has_many :images Image belongs_to :painting On the edit screen the user can edit the Painting data as well as upload pictures for a thumbnails and full size image. The Image model extracts filename, width, and height from the uploaded file, saves those
2006 Apr 28
2
validates* gives me problems
Hi, In Debian/testing (mysql-5.0.20, ruby1.8, rails 1.1.0) Im trying to follow up the fourdaysonrails tutorial, and when putting: validates_uniqueness_of :category, :message => "Already exists" in /myapplication/app/model/category.rb I get: NoMethodError in Categories#create undefined method `category'' for #<Article:0x407f6418> RAILS_ROOT:
2006 Jan 13
1
validating without saving
i am trying to validate without saving use the valid? method on my object. however i keep getting the following error (that i reproduced in console) "NoMethodError for field" Any ideas ? thanks adam Loading development environment. >> p = Post.new => #<Post:0x407b6050 @attributes={"created_on"=>nil, "subcat"=>1, "cat"=>nil,
2006 Mar 31
10
ruby help / if (cond or cond)
Why this code doesn''t work as expected? It raises exceptions everytime. Tried with || operator, too. validates_each :x, :y do |record, attr| record.errors.add (attr, ''between 1 and 100'') if (attr.to_i>100 or attr.to_i<0) end -- They say money can''t buy happiness? Look at the smile on my face... ear to ear, baby!
2006 Jun 19
3
can''t dump anonymous class Class
I''m trying to create a document upload system, where most of the code is the super class Document and just the path to file on the system is controlled by the sub classes. When I attempt to use my code, I get the following when I try to save the document. can''t dump anonymous class Class Any ideas? ** Migration ** class CreateDocuments < ActiveRecord::Migration def
2006 Aug 09
1
Migrating a Field to External Model
I have a model Product with an attribute ''brand''. Currently it is a simple attribute, however, I am migrating it to a separate model Brand so that I can have other attributes with each brand. I created the the model and created and ran the migration to create the new table. So far so good. Then I created a separate migration to transfer the data. The up method
2007 Jun 24
6
mocking errors
What is the correct way to mock out the errors on a Rails model? I''m assuming i need to say @mock_thing = mock_model(Thing) @mock_thing_errors = mock("errors") @mock_thing_errors.should_receive(:full_messages).and_return("An error") @mock_thing.should_receive(:errors).and_return(@mock_thing_errors) Just wanted to check the best practice on this kind of thing and how
2006 Feb 28
1
adding to errors in controller?
def update @product = Product.find(params[:id]) @product.attributes = params[:product] if params[:main_image] image = Image.new params[:main_image] if image.save @product.main_image.destroy if @product.main_image @product.main_image = image else @product.errors.add_to_base(image.errors.full_messages.join(", ")) end end
2006 Jan 29
8
Determining width and height of image files
I''m trying to figure out how to determine the width and height of images that are uploaded through my app. Either from the posted data or the file I save to disk. I''ve been searching around for info but no luck; I''m completely at a loss. Any suggestions or pointers would be great. Project background: The site is an artists portfolio site. The images are thumbnails
2006 May 16
2
Validate Before Delete
I have an Order model with a ''status'' column. What I want to be able to do is validate that the status of the Order is not completed before it is allowed to be deleted. I tried the following method in my Model, but it appears that this only works for an :update or :create on the record. Anyone know how to do this, and if it should be in the model or the controller?
2006 Feb 22
3
Unit test failure - nil object?
I''m following instructions in the Agile book, page 146 for testing an object update to the database. Here''s my code: def test_update assert_equal "jack@smiths.com", @user.email @user.email = "jack@smiths.org" assert @user.save, @user.errors.full_messages.join("; ") @user.reload assert_equal @user.email,
2008 Aug 31
0
Bug#474239: marked as done (spamassassin: spamd logcheck file doesn't work with shortcircuit enabled)
Your message dated Sun, 31 Aug 2008 19:32:06 +0000 with message-id <E1KZsec-00064d-FQ at ries.debian.org> and subject line Bug#474239: fixed in logcheck 1.3.0 has caused the Debian Bug report #474239, regarding spamassassin: spamd logcheck file doesn't work with shortcircuit enabled to be marked as done. This means that you claim that the problem has been dealt with. If this is not the
2009 Jun 17
2
validates_uniqueness_of fails on STI in Rails 2.3.2
I''ve got something like this: class Position < ActiveRecord::Base end class CartItem < Position validates_uniqueness_of :product_id end When I try to save CartItem I get this error: ArgumentError: wrong number of arguments (1 for 2) from /home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/validations.rb:758:in `exists?'' from
2007 Jul 24
4
Possible Bug
I''m trying to test some code that has validates each and I''ve got a very strange failure Mock ''Book_1027'' expected :store_with_privacy? with (#<Clip:0x1a99b96 @name="Clip_1025">) but received it with (#<Clip:0x1a99b96 @name="Clip_1025">) The Spec it "should check that a book can save a clip" do @user =
2011 Oct 25
1
Customizing errors
Hello fellow Rails devs, I had a slight problem with validation messages. I had a Post AR model that has an :author_name attribute. Now if a validation goes wrong, I would like the message to say: "Name of author can''t be blank" as opposed to "author name can''t be blank". I have tried looking into the Rails Guides for I18n #5 but it seems
2007 May 09
1
Custom validation error messages.
Hi all, I have a few questions regarding the error messages which are produced by default. For example, if I have "validates_uniqueness_of" I may get an error message "Surname has already been taken'' What if I want a custom message without prefixing the attribute name? I''ve come across a plugin which allows me to do this: validates_uniqueness_of :name, :message
2005 May 19
2
Bug#305932: rsync on a directory transfers the files of this directory
Hi, I got the following report from a Debian user, about --files-from transferring the contents of a dir (i.e. including the files in it) specified in the input, even thugh the files aren't listed in the input. This happens only when the dir name ends with a slash. I asked him to cook up a script to reproduce this (as it wasn't quite clear to me at first what happened exactly). Any
2011 Feb 07
7
feature request
Hi, how about to provide a simple way to forward raw file descriptors through ssh tunnels. something which may provide a way to write something like : (echo 3; read > out3) |& exec 3<&p 4>&p echo 5 >| out5 exec 5<> out5 echo 1 | ssh -d 3:rd -d 4:wr -d 5:rw ' read <&3; echo $REPLY >&4 read; echo $REPLY read <&5; echo $REPLY >&5