similar to: validations on a field

Displaying 20 results from an estimated 4000 matches similar to: "validations on a field"

2006 Apr 13
1
Model is not a class
I''m trying to specify a model in a controller, but rails gives me "Account is not a class", where Account is my model name ... This is my model: class Account < ActiveRecord::Base validates_presence_of :email, :email_confirmation, :username, :password, :password_confirmation validates_format_of :email, :with =>
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
2010 Nov 11
5
ActiveRecord query
I have these sql code in postgresql "SELECT * from convenios where id NOT IN (SELECT convenio_id from solicituds where usuario_id=?" but don''t find a way of used it in rails except find_by_sql. There is a another way?? class Usuario < ActiveRecord::Base belongs_to :persona has_many :solicituds, :dependent => :destroy has_many :convenios, :through =>
2010 Aug 28
1
validates_uniqueness_of missing in rails 3.0 rc2?
Has anybody noticed validates_uniqueness_of missing in rails 3.0 rc2? I''m not sure if this is a bug or I''m just doing something wrong. Here''s what I''m doing. Class 1: class Title < ActiveRecord::Base validates_length_of :language, :is => 3 validates_uniqueness_of :language, :scope => :book_id validate :language,
2006 Aug 14
3
validating required fields during an update?
I have a User model with an email attribute. I''m using the following validations: validates_confirmation_of :email validates_format_of :email, :with => RFC822::EmailAddress, :message => "must be a valid address in the form user@domain.com" validates_uniqueness_of :email, :message => "address has already been taken. If you''ve forgotten your
2006 Apr 14
1
Validating Existing Models
I''ve got a user object which has quite a few attributes mapped to the database. As of right now I''ve got some validations in the model like: validates_presence_of :password, :message => "You must specify a valid password." validates_confirmation_of :password, :message => "Password doesn''t match the confirmation." validates_presence_of
2006 Jul 04
1
LoginGenerator Problem
I am trying to make a barebones login system based on this example (which in turn is just standard RoR login) but when I enter a user name and password, it says the login is unsuccessful every time. I am not sure where I am going wrong. Here is all relevent information CREATE TABLE `users` ( `id` int(6) unsigned NOT NULL auto_increment, `login` varchar(20) NOT NULL default
2006 Jan 12
1
A really newbie question
Hi, I have been playing around with Ruby after reading so much about it, and so I started tweaking with auto generated scaffold. But it seems like I must be missing something, can someone else please help me take a look and give me a couple pointers? In short I was trying to make a class User that has a method addupdate with 2 parameters (alias and email) which would either update the
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,
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,
2006 Jun 05
2
When adding a record in console, a parameter comes in as null even when I set it
In console, I am trying to create a User but the :account_id does not come in. Console just gives me back :account_id => nil. Obviously I''m trying to set it though. Silly console... But, I can set the account_id column in my controller like so: @user = User.new(params[:user]) @user.account_id = account.id @user.save Here''s what I give to the controller: User.create :name
2005 Dec 29
7
belongs_to causing NoMethodError exceptions ... ?
I''ve got a really strange problem using belongs_to. I apologize in advance for the length... this is going to take a while to explain. Basic idea: Creating a User requires that the user enter an email address and activation key that matches an existing PendingUser. After creating the user successfully, that pending user should be marked as "used". The problem: When I
2006 Jan 03
6
Am I going too far or Rails is just confusing? was {validates_presence_of *_id attributes}
Thanks for the input Blair Zajac and Chris (Nolan and Hall), and for others. If all of you have time, please follow this (the question still relates to the previous posts by me): I have provided full steps to reproduce the symptoms. If it matters, I''m running Ruby 1.8.2, Rails 1.0, and MySQL 5.0.15 on Windows XP Professional. 1. First, the setup MySQL ----- create database testdb;
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
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''
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
2005 Nov 28
4
validates_format_of nil
I''ve noticed that validates_format_of will return invalid if the field is nil. Question 1) How should we declare a validation that will validate it with a regex if it is set, but, if the field is not set, just move on Question 2) Why is it done this way? The other validators are only invoked if the field is set . If you want to declare the field mandatory, you add a
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 Oct 23
11
validates_confirmation_of not working?
I just can''t get validates_confirmation_of working for the life of me!... It''s not the first time I''m having problems with it but I just never understand why!... This time I pretty much followed *exactly* the example in Agile Rails Development and still...it just won''t work! I put 2 different passwords in the form and it doesn''t trigger an error,
2006 Jan 19
4
validates_presence_of
I am just going through the book and I come across a problem with the code in the app/models: validates_format_of :image_url, :with => %r{^http:.+\.(gif|jpg|png)$}i, :message => "must be a URL for a GIF, JPG, or PNG image" It seems to moan when it''s empty even though I removed :image_url from validates_presence_of. How should I make it optional?