similar to: (2.3.5) removing validations

Displaying 20 results from an estimated 2000 matches similar to: "(2.3.5) removing validations"

2011 Mar 01
0
(2.3.5) removing validations
(sorry for misposting this to rubyonrails-core earlier) Today I tried to remove (actually overwrite) a validation from a model, from within a plugin. This was the original validation: validates_length_of :login, :maximum => 30 This was the only code I could come up with to replace it: def self.included(base) base.class_eval do @validate_callbacks.delete_if { |callback|
2009 Feb 04
2
delete_if does not work on associations
I tried to user delete_if on an association: class Group < ActiveRecord::Base has_many :memberships, :dependent => :destroy has_many :users, :through => :memberships ... end This is the controller method, trying to use delete_if. Although some elements are removed (s2 < s1), the save method does not update the association. def intersect_or_remove_group other_group =
2007 Oct 13
4
Chapter 9
Hello, I''m currently stunk on this issue for few days and I do not know how to get it fixed. The system always raises this error message : order is closed and here is my order.rb: class Order < ActiveRecord::Base include ActiveMerchant::Billing before_validation :set_status attr_protected :id, :customer_ip, :status, :error_message, :updated_at, :created_at attr_accessor
2006 May 26
4
shouldn''t this work? - session[:array_of_objects].delete_if {|x| x.id == params[:id]}
I am saving an array of active record objects (college courses) in the session as session[:course_list]. This is the cart for a registration controller. If a student chooses to delete the course from the list I get the :id as params[:id]. However if I do session[:course_list].delete_if {|x| x.id ==params[:id]} does not work. session[:course_list].delete_at(idx) works. Ocourse to do this I have
2011 Apr 18
2
acts_as_commentable validations
Hi all, I recently started back up with Rails and things are going well up until now. I''ve set up acts_as_commentable in my Post model and it''s working great. Problem is users are able to create a "blank" comment. I''ve added the following validations in the comment.rb file generated by acts_as_commentable to limit the comment length: [code]
2006 Sep 25
2
@article.article_groups.delete_if... Dosn't work!
If I try: @article.article_groups.delete_if {|x| x.group_id == x.group_id } It does nothing. If I try: articletmp.article_groups.each{ |x| @article.article_groups.delete(y) } It deletes some of the groups. @article.article_groups.clear works. Why dosn''t the to first examples work as expected?? Do I have to put groups I don''t want to
2012 Aug 14
3
validates_format_of :message not working, validates_length_of :message is working
I''m using validates_format_of and the validation I want to do works, but I can''t get an error message to be displayed if the data is invalid: validates_format_of :mobile, :with => /\A[\+0-9]+\Z/, :message => " - Wrong" I have another validation some where else that does display the error message: " - Name is too long" validates_length_of :name,
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
2006 Aug 17
2
validates_length_of with char field
I am new to ruby/rails and am having a problem with validates_length_of. It seems to work fine on a varchar field, but when I try it on a char field the extra characters are silently truncated and the message appears that the record was successfully updated. How can I get my app to produce my error message instead? I''ve tried various variations, but here''s one of my tries:
2006 Aug 08
12
delete_if doesn''t work for has_and_belongs_to_many
I''m using Rails-1.1.4 with Ruby-1.8.4 So let''s say I have 2 model classes: class Item has_and_belongs_to_many :things end class Thing has_and_belongs_to_many :items end i = Item.new i.things << Thing.new( :value => "Something").save i.things << Thing.new( :value => "Something Else" ).save i.save Fine, now I have two records in the
2006 Jan 20
3
Is there a way to validate a model w/o saving it?
I have some code in my controller which looks like this: if request.post? and @account.save and @user.save ... end and in my Account and User models I have many :validates, like so account.rb validates_presence_of :subdomain, :on => :create validates_uniqueness_of :subdomain, :on => :create, :message => "is already being used" validates_exclusion_of
2006 Jan 07
3
user engine question
I''ve created an array of hashes in UserController#initialize to describe a menu: @menu_array = [ {:menu => ''home'', :controller => ''home'', :action => ''send_home''}, {:menu => ''user list'', :action => ''list''}, {:menu => ''login'', :controller =>
2005 Jul 07
3
NameError Exception
Ruby/Rails n00b here so go easy on me... I''ve been wracking my brain trying to figure out what is wrong here. I''ve checked all my models for the appropriate belongs_to, has_many, etc. I''ve checked to make sure I''m using singular and plurals in the right spot. I''ve checked my syntax around all my "within"''s and nothing seems to fix
2009 Sep 19
1
validations on a field
hi, i have a model with 2 validations on a field example: validates_presence_of :email validates_length_of :email, :within => 6..100 #r@a.wk validates_uniqueness_of :email validates_format_of :email, :with => Authentication.email_regex if i do the submit of form for a new object of the model with a blank mail i receive 4 errors. In this case i want receive
2006 May 09
5
How to use gettext in plugins?
I use rails-engine as a plugin of the application and I want to localize the validate message from the plugin: validates_length_of :login, :within => 3..40, :on => :create, :message => N_("%{fn} is too short (min is %d characters)") It can not display the according language,where should i set it? I have tried to add require ''gettext/rails''
2006 Jun 12
2
conditional validation
Hi how can I validate a field only if another field is set to a specific value? I tried to use validates_length_of :fieldname, :maximum => 100, :if => :otherfieldname == ''myvalue'' But doesn''t work Thanks Paolo
2006 Mar 10
2
validation null objects and objects with data
I have a model where initially, they we don''t insert an gov_id value because it isn''t known. The field is given a value of "" because it is on the form. I then added code to the ''create'' method to set that value to nil if it is blank which seems to be fine but then it fails this validation (if NULL) validates_length_of :gov_id, :maximum =>
2013 Sep 17
4
Rails 4 deprecation of in-place edit methods for collection associations
Hi everyone! For those of you who are not noticed the in-place edit method for collection associations are broken in the current rails release - 4.0.0, and here''s what is cooking in the rails master https://github.com/rails/rails/commit/1a40be02113287d9a003f8224e91b9f623857f4b and this https://github.com/rails/rails/pull/12227 In short: it looks like things like has_many.reject!{},
2007 Jan 06
3
speeding up pagination
I need help to optimize a query (sort of ...) if params[:debit] == "on" @schools = School.find(:all, :conditions => ["name like ?", "%#{params[:search]}%"], :order => ''name'') @schools.delete_if { |s| s.debit <= 0 } @school_pages = Paginator.new self, @schools.length, 20 The problem here is that
2006 Dec 29
2
update_attributes fails: ReadOnlyRecord
I''m trying to update a record, but it just stops with "ActiveRecord::ReadOnlyRecord". I don''t understand why, because I never wanted my model to be read only. Relevant code: Controller: def edit @project = find_project if request.post? @project.update_attributes(params[:project]) if @project.save flash[:message] = _(''Project was