similar to: validates_presence_of

Displaying 20 results from an estimated 4000 matches similar to: "validates_presence_of"

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 Jan 20
8
validates_confirmation_of not working
is there any special requirement for validates_confirmation_of ? I am trying to make sure 2 passwords are equal (cleanly the rails way).. In my view i have two fields with id user[password] and user[password_confirmation]. in the model i have validates_confirmation_of :password, :message =>"Passwords do not match " Am i missing something here ? thanks adam
2006 Mar 22
3
Problems with validates_presence_of...anybody?
Hello everybody, I have been developing small applications in Rails from quite some time. But lately, I came across a bug which I have not been able to correct. If anybody could help me with it, would be of great help thankyou. Actually, the problem is that I have a form in my application with some set of fields. Now what "validates_presence_of" should do is that if I submit the form
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 Mar 14
4
validates_confirmation_of has stopped working
Hi Railers, I''m past considering myself a noob in Rails land - I think what I''m up against here is more of a bug or an anomaly that I''m unaware of (or that has changed in a recent version). I had a fully working validates_confirmation_of :email_address field in my app - was one of the first things I set up, extremely simple, been working for a long time. Then one
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 Dec 04
3
uninitialized constant Product
I am actually following the instructions/code snippets from "Agile Web Development with Rails" and got as far as page 73 where I did ruby script/generate controller Store index, then edited store_controller.rb to class StoreController < ApplicationController def index @products = Product.salable_items end end and product.rb to: def self.salable_items find(:all,
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 =>
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,
2008 Mar 15
9
Spaces in Ruby on Rails and how to avoid them!
Hi, I just started learning ruby on rails and I am having hard time with white spacing! Here is the piece of code that will not work: validates_format_of :image_url, :with => %r{\.(gif|jpg|png)$}i, :message => "must be a URL for a GIF, JPG or PNG image" and here is the piece of code that will work: validates_format_of :image_url, :with => %r{\.(gif|jpg|png)$}i, :message
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
2005 Oct 14
7
validates_confirmation_of not working
Hello, I''m having a weird problem in my user model. For the change_password method I have the following: def change_password(oldpass, newpass, confirmation) oldpass = self.class.myhash(oldpass) reload passhash = self.password self.password = newpass self.password_confirmation = confirmation if valid? and oldpass == passhash save! else # valid?
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 Feb 19
3
Rails urls & the AWD book
Greetings! I''m having a hard time understanding the way Rails handles urls. I''m specifically having real trouble with the image_urls in the Depot app in the Agile Web Development book. If I enter "\image\file.png" in the Add Product page, the image is displayed in the other views and Properties shows http://localhost:3000/images/file.png If I leave off the leading
2006 Jul 17
19
updating model
hello, i am writing a simple user login system. when registering a user account, i have two field: password password_confirmation which are validated using validates_presence_of validates_confirmation_of and these are then used to generate a password hash which is stored in my database when i want to update the record (without changing the password and entering new values for password and
2006 Apr 26
1
Possible acts_as_authenticated bug (or rails)
The code that comes with the plugin uses a method that looks like this: def password_required? crypted_password.blank? or not password.blank? end with validations that look like this: validates_presence_of :password, :if => :password_required? validates_presence_of :password_confirmation, :if => :password_required? validates_length_of
2005 Dec 29
4
Images in Agile Web Development with Rails
Hi, I am working through Agile Web Development with Rails and I am at pg 69 second last paragraph says "put some images in the public/images directory......" how do you code the link that is stored in the data base I have tried http:public/images/name .jpg with no avail I have tried the fully qualified address http://home/../../../../name.jpg also with no luck. How should I code this?
2006 Jul 27
2
Creating multiple objects from form data
I''m in the process of creating a sign up form for an online application. The form collects account info, company info, and then info for an administrative user. The method looks like this: def create @account = Account.create!(params[:account]) @company = @account.companies.create!(params[:company]) @user = @company.users.create!(params[:user]) end However, this inevitably fails
2006 Jun 18
10
acts_as_enumerated
Hello All, Any one using acts_as_enumerated? I need help using (I like that it caches values in memory) I am working on a dating website and there are lots of options I want to store as enumerated like Status; divorce, single, Sex: male, female Eye color; blue, brown, green.... and lots more.... But I do not wanna keep them in seperate tables, and wanna keep them all together. Anyone has a
2006 Jul 05
2
Serialized object behaves weird
Hi! I got a class named EinsatzFilter which I serialized to session. Before saving to session it works afterwards I keep getting the message: "undefined method `to_s'' for #<Person:0x38c6ab8>". "Person" is a from ActiveRecord::Base inherited class. Code: class EinsatzFilter include ApplicationHelper attr_reader :personen, :monat, :projekte, :kunde