similar to: Why won't Rails update my object attributes?

Displaying 20 results from an estimated 1200 matches similar to: "Why won't Rails update my object attributes?"

2006 Feb 14
2
confusion with validates_inclusion_of
It appears that if your trying to use validates_inclusion_of for a string value allow_nil wont work. For example, if I have an attribute :year which is stored as a varchar then: validates_inclusion_of :year, :in => "1980"..Time.now.year.to_s, allow_nil=>true will successfully validate the range but will not allow an empty input field to be submitted. However, if :year is
2007 Jul 06
2
validations of "type" when using Single Table Inheritance
Sorry if I''m just dumbing out, but is there a reason that when using Single Table Inheritance Rails doesn''t really validate the "type" field or provide some mechanism to do so? seems like a good way to corrupt a database. Because the "type" is also a special attribute, I had to resort to an ugly hack like: class ActiveRecord::Base def type_attr
2007 Jul 24
13
Problem with validates_length_of an integer
Hello guys, I''m trying to validate the input of an integer from a form, here is a bit of code: This is the definition of the offending column in the migration: t.column :position, :integer, :default => 0, :limit => 3, :null => false And here is how I try to validate it inside de model: validates_length_of :position, :within => 1..3 And this is the exception I get when I
2006 Jul 27
9
Introspecting validates_presence_of
Hello people, I''d like to detect whether an attribute of a model has vaildates_presence_of applied to it so I can automatically apply a mandatory (*) to the field...it doesn''t look easy...any ideas? Cheers, -- Dan Webb http://www.danwebb.net
2009 Jan 12
2
validates_presence_of fails with false boolean
This almost feels like a bug to me, since false is not nil. (i don''t think!) Using v_p_o on a boolean field fails validation if the field is passed with ''false''. It passes validation in the case of true. How can I validate _presence_of a boolean if it is submitted false? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~
2006 Apr 08
4
Calling validates_inclusion_of out of default namespace
Hi, I''m trying to run the "validates_inclusion_of" method in a before_save hook, because the range is dependant on the related data. But I can''t figure out how to call it. When calling it normally, it says it can''t find it. I''ve tried several combinations like "ActiveRecord::Validations.validates_inclusion_of", but I can''t seem to
2011 Jun 19
10
validates_numercality_of with allow_nil.
In the model I have: validates :square_meters_public_land, :barrier_meters, :numericality => { :greater_than_or_equal_to => 0 }, :allow_nil => true but if, in the field, on create, I don''t insert a value I have the error "field is not a number". -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To
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 Mar 13
13
validates_inclusion_of disabling
Hello all. I have a problem using validates_inclusion_of. I need to switch off some validations during a migration period, is there a way? I tried to use if, with a static method of one of my models, but the behaviour is something strange It seems that the static method should be in a string to be evaluated. And the order of the elements in the if is counting... :if => (:some_field
2007 Jan 17
2
rake test and validates_inclusion_of
Hello, I am just starting off with Rails, so I apologize in advance if there is a terribly obvious answer to my problem. I''ve done some searching and found similar problems to my own, but nothing which yielded a solution. I have a handful of models that I am unit testing. The tests for each unit run successfully, but when I do a rake test, many of the tests fail. The assertions that
2007 Mar 29
2
Freebsd 4 error DSN stat=Service Unavailable after dovecot install
Hello everyone, I am getting an error message on FreeBSD 4 after I install dovecot. To start off, I create two regular users, testuser and testuser1. I send each user emails then I install dovecot. After installing dovecot I set up the users in Maildir format then proceed to send them emails and here is what shows up in the maillogs: Email to testuser3 - Mar 29 22:34:52 myserver
2006 Apr 03
4
validates_numericality_of, :allow_nil => true?
Is there a way to use validates_numericality_of and still allow null values? I have a model with some optional values that can be nil, but if they''re present, they must be numbers. Will I need to construct a custom valiation for this, or is there some method built in? Seems like it would be a common enough need. Jeff -- Posted via http://www.ruby-forum.com/.
2006 Feb 20
1
extract month from date column
Hi, I have this rails query: @birthdays = Birthday.find :all, :conditions => ["user_id = ? and birthdate = ''2006-02-01'', @user_id], :limit => @birthday_pages.items_per_page, :offset => @birthday_pages.current.offset You can ignore the user_id, limit and offset part.
2005 Jun 09
1
PDC with LDAP backend login issue
Hi all, I'm very close to having a working setup after blundering through a couple of typing errors that cost me several days of my life, with the following config: Samba 3.0.14a as a PDC Suse 9.2 Professional LDAP (eDirectory 8.7.3) passwd backend Idealx scripts Windows XP SP1 I can connect to any of the samba shares just fine using any of the users I've created, from XP and from linux
2014 Oct 20
1
winbind/i­dmap­ issue on samba4 mem­ber s­erver
Oh! I think I did find the error now :-) If I understand "NOW" correctly, I have also to assign a UID to EACH of my AD users in ADUC tool in the [UNIX Attribute] tab, is that correct? I just tried out. In ADUC tool I did choose "testuser3", and on the [UNIX Attribute] tab I activated the NIS domain so it reflects to "MYDOM". Then by default there was UID=10000, I
2007 Dec 27
4
validates_file_format_of only when is there an image
i have a model with this: file_column :image validates_file_format_of :image, :in => ["gif", "png", "jpg"] If inthe form the user not insert the image i receive an error. If i remove: validates_file_format_of :image, :in => ["gif", "png", "jpg"] it works. Is possible do the validation only when user insert the image in form? i
2011 Feb 16
5
validates_inclusion_of with range on ruby 1.9
I found out today that Range#include? behaves differently on 1.9 than on 1.8 ( http://rhnh.net/2009/08/03/range-include-in-ruby-1-9 ) In order to deal with various edge cases, instead of just checking whether range.first <= value <= range.last, in ruby 1.9 include? steps through all the values in the range, checking for equality. This is of course a lot slower - in my case, checking a date
2007 Mar 09
2
Blank fields getting validated
Hi, I am not sure if this is already answered in this list. I couldn''t find an answer. So I am posting the question. I have multiple validations for a field. For example: validates_presence_of :contact_email validates_format_of :contact_email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message => "is not a valid email
2005 Feb 13
5
Select Enumerated Values with FormOptionsHelper
Hey, I''m new, so apologies if I''ve overlooked obvious resources or violated any etiquette rules for this list. Since rails does not support the MySQL enum data type, I''m following David''s advice of using a varchar and storing the valid values in the application: http://one.textdrive.com/pipermail/rails/2005-January/001536.html So here''s my
2005 Feb 09
1
[DEFECT] ''validates_inclusion_of'' not working as expected (couldn''t post to Trac as it gave me an error)
Hello, I tried to post this as a bug on the trac site, but whenever I hit submit, I got the error message: --- Precondition Failed The precondition on the request for the URL /newticket evaluated to false. --- Anyway... Let''s say I have the following model classes: --- class Project < ActiveRecord::Base has_many :tasks end class Task < ActiveRecord::Base belongs_to