similar to: validates_overlap

Displaying 20 results from an estimated 60000 matches similar to: "validates_overlap"

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
2013 Mar 26
0
nested forms: use validate :some_method works in update mode only
I have a strange behavior when validating a record in a nested form. The association collection is empty when creating a new record and the validation does not catch the error. But when updating the same record the validation gets it right but continues to catch the error even after modifying the needed attribute value to make it pass. Here is the model: #timesheet.rb class Timesheet <
2011 May 21
1
Consequences of overriding update_attribute to force validation?
I know the debate of whether this should validate has been rehashed many times. My question is, what are the consequences of overriding this method to force validation? Will this break fundamental things? Will it break plugins? Is there a reason not to have a strict validation option? In my code I will never use this as I consider it a terribly broken method, but some gems use it and in one case
2013 Apr 03
1
validates uniqueness scope allow_blank/allow_nil -> validation error
I have this in a model: class GenreBadge < ActiveRecord::Base belongs_to :game, counter_cache: :genre_badges_count, touch: true belongs_to :genre validates :game_id, uniqueness: {scope: :genre_id}, allow_blank: true end When I get one existing genre badge genre_badge = game.genre_badges.first genre_badge.game_id = nil genre_badge.save! It creates an validation exception:
2010 Jul 23
7
fail rollback transaction with manual raise exception
With : PostgreSQL 8.4 or postgresql-8.3 rails 2.3.4 pg 9.x or pg 8.x I test this code: ========================= class NkiBatch < ActiveRecord::Base Bank.connection.transaction do bank = Bank.new(:name => "ddsjdsjdsjk") bank.save! raise ActiveRecord::Rollback.new end end and this: ========================= class NkiBatch < ActiveRecord::Base
2011 Dec 08
1
Determine Bank Name from Routing Number
Hello, I am working on a project where we need to look up bank name (only US banks) from routing number. I will like to use something that is dynamic and has up-to-date information. Does anyone has suggestions on how to accomplish this? Thanks a lot in advance!!!! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups
2013 Mar 25
1
validates presence of foreign key fails in nested form
I''m using accepts_nested_attributes as follows: class Timesheet < ActiveRecord::Base attr_accessible :status, :user_id, :start_date, :end_date, :activities_attributes has_many :activities, dependent: :destroy has_many :time_entries, through: :activities accepts_nested_attributes_for :activities, allow_destroy: true end class Activity < ActiveRecord::Base attr_accessible
2011 Apr 18
3
paypal with Active merchant
Hi, I am integrating paypal service in my application using Activemerchant. Now I want to know how to use ActiveMerchant to make payment to Bank or Credit card ? for example: I am seller and I want to pay some amount to somebody. I want to pay such amount which will be credited in somebody''s bank account or credit card directly ? Please reply me as early as possible. And also suggest
2011 Dec 13
3
Validates presence
Hi everyone, I just need a quick help :) What is the best way to write some code in :presence option? I have a Question model and one of the fields is question_type: - example question - static question Each question has alternatives, and each of them has scores What I want is to validate the presence of :score, but when its only on the static question. I dont want to validate the presence
2014 Mar 22
0
Validation error messages for JS
Hello, I try to create javascript client side form validation for rails models and I don't wont to duplicate error messages in language yml files (one for models and one for javascript). I wont for example to generate json object with list of all available error messages for some active record rails model. Is there any way to get these error messages before I validate model. In rails
2011 Sep 18
0
how to split, remove part of data in column with spreadsheet gem
Using spreadsheet gem and rails MY CODE GOES BELOW: book = Spreadsheet.open ''excel-file.xls'' sheet = book.worksheet 0 book.write ''output-file.xls'' and here goes the first problem: I want to remove data that comes after ";" (semicolon) in a column. Example below. FULTON BANK NA;FULTON BANK I just want it to be FULTON BANK NA for example.
2010 Oct 03
7
Rails 3, Validates, Custom Message
In Rails < 3, I could have a validation on model such as: validates_presence_of :name, :message => "some custom message here" If I try something similar in Rails 3: validates :name, :presence => true , :message => "some other custom message" obviously, it throws an exception. So the question is, in Rails 3, how to you give a simple custom message? Do I need to
2011 Mar 02
2
Nested forms validation problem
Hi All, I''m trying to learn Ruby on Rails and have got an issue with the validation of a nested form. I think I have got it setup correctly as it appears to be saving the data as expected, but it is not wrapping the CSS class (field_with_errors) to the fields, and if data is entered into the nested fields it disappears on form submit (if there are validation errors). The validation
2011 Feb 28
2
form level validation, where to do it.
Form level validation involving enforcing a relation between two or more form inputs that may not even be in the model: I am building a form that will query a range of records between two dates. The form ask for a starting data and a ending date. I want to validate that the user selected a starting data before or equal to the ending date. It seems that this validation should happen in the
2010 Dec 15
2
skip password validation in authlogic
i am using authlogic for user authentication and authlogic-connect for facebook and twitter signup.what i need is that i need to skip validation on the password field if user is signup via facebook or twitter.my environment is rails 3 and ruby 1.9.2. i have acts_as_authentic in my user model.however i can skip phone number validation like this validates :phone_number, :numericality =>
2010 Dec 28
0
HABTM associated record presence validation
Given a HABTM relationship, for example between Products and Categories, is it appropriate to add a validation such as the following? # product.rb validates :categories, :presence => true This works for me. If there''s not at least one associated category then validation fails, and if there is then it passes. However I''m wondering if it''s correct or if there might
2012 Dec 05
0
Action Mailer 3.2.9 retruns duplicates in deliveries array
I am extracting a standalone batch application from a Rails 3.0.1 project. This requires only ActiveRecord and ActionMailer. In my testing I set ActionMailer::Base.delivery_method = :test This causes the mail to be delivered to the ActionMailer::Base.deliveries array. However, I am getting two of the test email messages placed in the deliveries array instead of just one. For example:
2013 May 07
3
validates :uniqueness apparently doesn't
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.3.0] Rails 3.2.13 I have a validates ... :uniqueness constraint on one of the attributes of an ActiveRecord class. In my test suite, I set the attribute from the same attribute in a record in the fixture. I then send invalid? to the object under test. invalid? returns _false_, and the .errors object for the record shows no errors. A
2011 Sep 07
6
FactoryGirl doesnt produce unique names?!
Hey, I got following very simple test case: require ''spec_helper'' describe Country do it "should create a new instance given valid attributes" do Factory(:country) end end Factory looks like: Factory.sequence :country_name do |n| "Country #{n}" end Factory.define :country do |c| c.name Factory.next(:country_name) c.nationality "Foo
2013 May 19
5
update_attributes() for a single column
I was just faced with a strange ROLLBACK exception when attempting to execute this code: $ rails console user = User.first User Load (1.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 => #<User id: 1, name: "Michael Hartl", email: "foo-+RB1Aph5k6s@public.gmane.org", created_at: "2013-05-12