similar to: Why are both of these validations not working?

Displaying 20 results from an estimated 100000 matches similar to: "Why are both of these validations not working?"

2009 Apr 02
3
error_messages_for does not display the error
Hi all I''ve approached Rails since a couple of months to develop a quick application for my company. Fantastic framework. As every noob, I do have some gaps to cover. The one which is giving me a little frustration, generated by my lack of knowledge is as follows. I need to make sure the region object is not deleted if there are countries associated with it. I solved this by putting a
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
2008 Jan 23
2
Combine custom validations with helpers
Hi I have a model that uses several validation helpers, for example validates_presence_of. Now I want to add a custom validate method for a very complex validation. I override validate in the model and it works by itself but when I do this the helper validations stop working. I guess the helper methods rely on the ActiveRecord::Base#validate original method in some way. Has anyone any suggestions
2006 Oct 11
1
Polymorphic Validations
Hi Everyone, Ran into an interesting case last night, and I was hoping that someone on the list here could give me some guidance. I''ve got a Polymorphic association for Addresses (which can belong to two different models). The catch is, one model requires a strict, precise address, and the other only requires a City, State and Postal Code. I want to use :validates_presence_of :street,
2006 Apr 10
3
Problems with multiple ActiveRecords and Validations
Hi all, I am a RoR newbie and have the following scenario set up: There are 2 ActiveRecords involved, the first one being "User", the second one being "Visibility". The corresponding users table holds address informations regarding a User. The visibilities table holds visibility settings for the individual columns of the users table (i.e. firstname, lastname, country
2010 Oct 06
0
Error customization problem.
Hi, I have following models class User < ActiveRecord::Base has_many :addresses, :as =>:addressee, :dependent => :destroy accepts_nested_attributes_for :addresses, :allow_destroy => true end class Address < ActiveRecord::Base belongs_to :addressee, :polymorphic => true validates_presence_of :address1, :maximum => 50,:message => "Address1 cannot be
2007 Jan 20
0
[PLUGIN] instance_validations
Get info at http://evang.eli.st/blog/2007/1/20/instance-validations-plugin (until I set up an open svn repository). Download link is at the bottom of that page InstanceValidations =================== ActiveRecord lets you define validations at the class level. This plugin lets you define validations for ActiveRecord instances. Take the following ActiveRecord class: class Chicken <
2012 Nov 17
2
Help needed for error in foreign key validation
I have two models bank and country. User should only associate a Bank with a country id present in the country table and I put validates presence of country to enforce it but i get error mysql2::Error: Unknown column ''countries.bank_id'' in ''where clause'': SELECT `countries`.* FROM `countries` WHERE `countries`.`bank_id` = 17 LIMIT 1 when updating the bank
2007 Mar 29
4
validates_length_of not working with :if ?
Hello, I''m trying to cut down the errors if the guy already getting the empty nickname, so he doesn''t get anything about the nickname is short. validates_presence_of :nickname This below is not working ? validates_length_of :nickname, :within => 4..40, :if => Proc.new { |user| user.nickname.length > 1 } nor this one below? validates_length_of :nickname, :within
2007 Jun 21
1
Validation Through Multiple Models from one Form
Hey All, I have a form that submits data to multiple models. I have class Man < ActiveRecord::Base has_many :notes has_many :contacts validates_associated :contacts, :notes validates_presence_of :first_name validates_presence_of :last_name class Contact < ActiveRecord::Base belongs_to :man validates_presence_of :contact_info class Note < ActiveRecord::Base
2006 Dec 16
2
Validate some fields only on object creation, not update
I''m having a problem with my User model. Originally I had alot of validation, including this: validates_presence_of :password_confirmation, :password validates_length_of :password, :within => 4..50 validates_confirmation_of :password However, this made it impossible to edit a user without setting his password, which I don''t want. So I tried to isolate the above validations
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,
2006 Nov 28
2
Twice the same code, but only once it seems to work
Hello, I am confronted with a very strange problem which I can not solve... and God I tried a lot, lost almost a whole day, but couldn''t find an answer: The idea is to have a form both in admin and in dir, in admin there will be some more fields that is why I have twice a form. In admin the form appears, in dir the form does not appear instead "þÿ New company" why is it that the
2007 Dec 13
4
Attachment_fu problems on updates
On the creation of a member the member''s picture uploads as it should. However, when updating the member, while selecting a new picture, an error is thrown: can''t convert nil into String RAILS_ROOT: /Users/chris/Documents/Projects/Rails/CommunityCMS/trunk Application Trace | Framework Trace | Full Trace
2007 Feb 26
2
boolean db fields set to false fail validation with validates_presence_of?
I have a model that contains a :boolean field. In my view, I have a simple select of Yes or No, which equates to true or false, respectively. If I choose yes and save, everything works great. If I choose no, my model fails validation as I have this set as a required field using validates_presence_of. I have checked the log and it''s definitely set to false, why would this fail validation?
2008 Jul 06
1
ActionView::Base.field_error_proc not getting an error field
In my User form I have standard field to get user record attributes (first_name, last_name and email) I also have a select drop_down to choose a role from an array first_name, last_name and email are user record attributes, but I defined the role name as a virtual attribute validates_presence_of :email, :last_name attr_accessor :role_name validates_presence_of :role_name, :if =>
2007 Oct 17
3
validates_presence_of validating twice?
I''m getting some weird behavior in one of my models. I have a model defined something like this class User < ActiveRecord::Base attr_accessor :password validates_presence_of :password end If I validate the model without specifying a password, I get ["can''t be blank", "can''t be blank"] for :password instead of just one "cant''t
2008 Oct 09
2
has_many validation the Rails way
Okay, this is something I run into a lot and don''t really have a great solution. Here is a simple example: class Blog < ActiveRecord::Base has_many :posts validates_presence_of :name end class Post < ActiveRecord::Base belongs_to :blog validates_presence_of :name validates_presence_of :blog_id end Now, if I want to create a blog and post at the same time I
2007 Mar 20
2
collection_select - why doesn't it work?
Hi all I guess this is quite a newbie question, but I''m just stuck here and don''t know why. <%= form.collection_select :origin_country, Country.find(:all), :id, :name %> gives me a select list with name="member[origin_country]". When submitting the form the following error is shown: Country expected, got String When I try <%= form.collection_select
2010 Apr 14
1
Rails validations app specific problems
Hi all, I have a unique workflow where it''s making the use of validations difficult. My app is for internal use in my company and I have a funky implementation (inspired by the e-commerce Railscasts episodes) of a cart. I have products which when I "add to cart" creates an order with a state of "incomplete". The product is a line item of my order. Hope that makes