similar to: Not working validation

Displaying 20 results from an estimated 4000 matches similar to: "Not working validation"

2005 Dec 17
0
bug? saving (valid) updated object results in validation error
Hi! I have an error that I don''t understand. It shouldn''t be happening, according to the documentation! I have a class, defined as below. > class Coupon < ActiveRecord::Base > belongs_to :product > belongs_to :account > validates_presence_of :product > validates_associated :product > validates_presence_of :voucher > validates_presence_of
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
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 May 04
2
validates* give me problems
Hi All, I''m newbie to this tool and following some tutorials I''ve came across with this problem when configuring my webpage: In Debian/testing, ruby1.8, rails1.1 I create my audio application which connects to a database (mysql) named audio with tables: articulos(id,titulo,descripcion,created_on,categoria_id) and categorias(id,titulo) after creating and modifying the
2008 Jul 17
2
problems with validation on STI
I have the following STI table: def self.up create_table :distributions do |t| t.string :type t.integer :simulation_id t.string :dist_name t.string :desc, :default=> ''fixed'' t.float :param1, :default => 5.0 t.float :param2, :param3 t.timestamps #fields for RscDist t.integer :resource_id #fields for LoadDist
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
2007 Nov 03
3
Birthdate validation
Hello everyone, I''m almost cracking my head trying to do this birthdate validation. It turns out that I can only accept users with at least 18 years old and I''m trying to validate it writing this code on my user.rb fil at app/ models class User < ActiveRecord::Base validates_presence_of :full_name validates_presence_of :street_address validates_presence_of :city
2006 Jan 11
0
Easy Question, I Think
I am just getting started with Rails, don''t know any Ruby, and don''t quite even get object oriented programming yet. I have tweaked my schema to The Rails Way and have generated a bit of scaffolding. I am trying to create a new Part, which references a PartName and a PartNumber. I can create a PartNumber on the fly, but the PartName has to exist. I have an inelegant solution
2006 Jan 12
0
Easy Question, I Think [re-post, sorry if dupe]
I am just getting started with Rails, don''t know any Ruby, and don''t quite even get object oriented programming yet. I have tweaked my schema to The Rails Way and have generated a bit of scaffolding. I am trying to create a new Part, which references a PartName and a PartNumber. I can create a PartNumber on the fly, but the PartName has to exist. I have an inelegant solution
2005 Nov 26
0
Model warnings along with Validations
Hi railers, Is there a simple method to extend Active Record to have similar functionality as the validate functions e.g. validate_on_find validates_acceptance_of validates_each validates_format_of validates_length_of validates_uniqueness_of etc... but only report warning on model attributes instead of errors(). I would like to save the model if there are warning and if the model is invalid
2006 Jul 24
6
error_messages_for not working
I have the following code and I am not able to get it working. The error message is not coming on the top, it is just getting displayed on a different page if I dont have the rescue block commented at the bottom. Model: user.rb require "digest/sha1" class User < ActiveRecord::Base validates_presence_of :eaddress, :fname, :passwd, :pcode, :country, :day, :year, :month, :gender,
2009 Nov 20
3
Ensuring that foreign key is valid
I am trying to set up a validation in a model to ensure that a record can''t be saved unless the foreign key it belongs_to is a valid record. My model says: class Admin < ActiveRecord::Base validates_presence_of :user_id validates_numericality_of :user_id validates_uniqueness_of :user_id validates_associated :user belongs_to :user end but I can still create an admin
2006 Jul 20
0
Refactoring common code to module
Hello Ruby users, I am stuck with the following problem: I have an access control list system, with multiple group, section and base classes. There are several section types (AroSection, AxoSection, AclSection etc.), several group types (AxoGroup, AroGroup) and several base Types (Acl, Axo, Aro, Aco). These share some common funcionality that only differs by name of the associations.
2006 Jul 20
5
How can I make has_many prevent a delete that would lead to orphans?
e.g. class Asset < ActiveRecord::Base validates_presence_of :asset_number, :make, :model, :location, :name, :serial_number validates_numericality_of :asset_number validates_uniqueness_of :asset_number belongs_to :user belongs_to :location belongs_to :asset_type, :foreign_key => ''type_id'' end class Location < ActiveRecord::Base validates_presence_of :name
2006 May 17
6
ActiveRecord#to_param
Hello, to implement some some kind of optimistic locking, I want to build a view, where an object is displayed together with a link containing the data of the displayed object. My first try looked something like <%= object.object_discription %> <%= link_to "action", :action => "take_action", :data => object %> this won''t work because object is of
2009 Nov 13
3
Encoding::UTF_8 missing?
I''ve just done a fresh reinstall of OS X Snow Leopard on my mac, and I''m having all kinds of problems with Rails, but the latest problem has me stumped. Whenever I run rake db:seed to populate my database I hit the following error: ** Invoke db:seed (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:seed rake aborted! uninitialized constant
2006 Mar 16
2
please help: "undefined method ''updated?''"
Hi, after updating to rails1.0 (using the debian package) and following the instructions at http://manuals.rubyonrails.com/read/chapter/120 I always get in my rails application the following error: "undefined method `updated?'' for #<Device:0xb6c95564>" when I want to save (create or update) an interface or device-object (as explanation: devices are servers, which have
2006 May 27
2
ActiveRecord::Base::find_for_create_modify
Hi, for some models I found that it''s easier to share the controller new and update code just to share the view code. At the front of every such action function I have to lookup if the object already exists, if so "find" it from the database and update the "attributes=". If there is no such object, "new" it with the attributes I''ve got from the
2006 Dec 11
2
Custom Validator
I want to add a custom validator in one of Model. For example Rails has inbuilt validation methods like validates_uniqueness_of, validates_presence_of . What I need is a similar kind of method (example: validates_line_items), that can run my custom code while saving, updating the record and can add custom error messages to the record. Please help me by suggesting how i can do this. -- Posted via
2007 Oct 24
3
jEdit for R
Hi, I just installed jEdit but have no clue, whether I can run my code a'la "ctrl-R" directly from jEdit script, or should source it from R command line, after saving it first in jEdit. thanks for any help, rob -- View this message in context: http://www.nabble.com/jEdit-for-R-tf4684065.html#a13384782 Sent from the R help mailing list archive at Nabble.com.