Displaying 20 results from an estimated 31 matches for "validate_presence_of".
Did you mean:
validates_presence_of
2010 Aug 11
6
rspec2 not working with shoulda
I am using rails edge. I am using gem "rspec-rails", "= 2.0.0.beta.
19" .
I have following code at spec/models/user_spec.rb
require ''spec_helper''
describe User do
it { should validate_presence_of(:email) }
it { should validate_presence_of(:name) }
end
Here is my gemfile
group :development, :test do
gem ''factory_girl_rails'', :git => ''git://github.com/thoughtbot/
factory_girl_rails''
gem ''shoulda''
gem "rspec-rails"...
2009 May 26
1
how does form_for and validate_presence_of work hand in hand
when we have validate_presence_of :name in the model and then when we
put in the create action that we re-render ''new'', then the form_for will
populate the fields, and error_messages_for ''story'' will have the
correct error message.
this is really great, and and the same time, this looks like mag...
2006 Jul 12
5
validates_peresence_of
...alidater that can point me in the right direction?
I''ve looked for extended documentation on ''validates_presence_of'' but i
can''t seem to find any.
I''m trying to make sure that i don''t enter a nil object in my database,
so i''ve added validate_presence_of to my Record Model.
i.e. -->
class Record < ActiveRecord::Base
validate_presence_of
end
I''m coming up with errors when trying this. Do i need to create a
function to handle the situation when i try leaving a field blank? Does
any one know of a good place to find detailed i...
2006 Apr 12
11
validate_presence_of not working for me
Hi all,
I just begun with RoR and going through the Agile development w Rails
depot example ATM. I did everything according to the book (i believe),
and after 3 hours of googling, reading docs, making sure i did
everything correctly i can not make the validate_presence_of() to work -
at least not as it looks in the book. My Product model looks like:
class Product < ActiveRecord::Base
validates_presence_of :title
end
however, if i leave the title field empty, and push create, the newly
created product is added to the list of products without any error
message....
2006 Apr 07
1
Validate_presence_of error in nested object is not displayed
Hi,
I have a contact object . This contact has a address object
>>Contact
class Contact < ActiveRecord::Base
has_one :address
validates_presence_of :first_name ,:last_name
end
.>>> Address
class Address < ActiveRecord::Base
belongs_to :contact
validates_presence_of :address
end
Addres has the following fields ; address, phone, fax, email
In the contacts_controller I
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
2012 Nov 18
3
remarkable activerecord association RSpec
...emarkable_activerecord" as required in
spec_helper.rb.
describe Authentication do
FactoryGirl.build(:authentication).should
belong_to(:user)
end
it "has a valid factory" do
FactoryGirl.create(:authentication).should
validate_presence_of(:uid)
end
i got error: : undefined method `belong_to'' and undefined method
`validate_presence_of''
what should be done now..?? thanks in advance
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups...
2006 Jan 17
2
change error messages for Validation helpers?
Is it possible to change error messages for Validation helpers? I am
writing an app against a existing database (so no control over column
names), but when there is validation error (e.g. with
validate_presence_of) I would like to customize the field name. For
example for telephone whose field name is PhoneNumber I would like to
chnage it to "Telephone Number cannot be empty" rather than "Phonenumber
cannot be empty". Is that possible?
--Jeet
--
Posted via http://www.ruby-forum.com/...
2007 May 05
10
have_one and have_present
...e, ''have_present'' doesn''t really tell me what is
interesting about having it present, or why it should be present. I
think ''require_attribute'' would be nice (''require'' would be even
better, but obviously that is a keyword). Or ''validate_presence_of'':
an { @asset.should validate_presence_of(:something) }
That''s a little more Rails-developer-friendly than customer-friendly,
but it still ''speaks'' better than ''have_present'' for me.
FYI - Jay Fields has a Validatable framework that includes...
2007 May 22
3
rspec_on_rails'' spec:doc and dry runs
...spec:doc task uses --dry-run, which doesn''t
jive well with rspec''s ability to write docs for you.
For example, I use the rspec_expectation_matchers plugin from
spicycode.com (scanned for a name, didn''t find one =), and end up
writing specs like:
it { @ticket.should validate_presence_of(:name) }
Which results in specdocs such as:
Ticket
- NO NAME (Because of --dry-run)
- NO NAME (Because of --dry-run)
- NO NAME (Because of --dry-run)
The examples_specdoc task for rspec itself, however, doesn''t use --dry-run.
Using dry runs presumably speeds things up significa...
2010 Jun 07
3
Model validation giving problem
Hi,
I have a member registration form which takes a "Name", "Login",
"Password", "Confirm Password" and "Location". In the user model I have
added the validation
validate_uniqueness_of :login, validate_presence_of :password, :name,
:confirm_password.
When the member tries to register every thing working fine. I am using
same form for user to edit his information. When the user come to edit
his information we are not allowing the user to edit the password so
that we are hiding those fields.
But whenever user...
2006 Jul 06
2
Validation Error
Hi all,
I''m trying to validate a data field.
I''ve added ''validate_presence_of :name'' to the record model, but when I
try to create a record i get an error complaining that it can''t find
data from another table that also is updated on that page.
Let me explain further,
On my ''record'' update page, I have data from another table displayed...
2006 Feb 10
1
Bizarre ActiveRecord::Errors/validation problem
...assert_equal "can''t be blank", @service.errors[''port'']
end
end
The first test passes fine, but the second test is failing on that last
assertion with:
=> <"can''t be blank"> expected but was
=> <nil>.
Any idea why the validate_presence_of method isn''t picking up the :port
column and providing an appropriate error message like it is with
name/status? Its not a reserved word or something is it?
To aid debugging, here is the output of:
@service.errors.each_full { |m| puts m }
=> Name can''t be blank
=> Status c...
2006 Jun 13
7
model validation across multiple views
I have a rather complex object with a number of attributes. For a variety
of reasons, I would like one view to create the object with only a couple of
fields completed, then a second and third view to finish all the fields. I
would like the model to validate_presence_of all these fields, since
eventually I need them all there, and I would like each page to validate its
portion of the fields that that view presents.
How do I best do that? The only thing I can think of is some kind of use of
single table inheritance, with each child object filling in a portion of...
2013 Nov 14
6
validates :boolean_field, presence: true misconceptions
Last night a friend of mine started ranting about validates_presence_of
:boolean_field returning not valid when the boolean field is false.
I checked the rails issues and this seems to be a pretty common concern
about the naming of ''presence'' .
Instead of changing the behaviour of the presence validator, I was
wondering if maybe the answer to avoid such misconceptions could be
2007 Oct 19
11
Patch idea for rspec_on_rails
I recently wrote a matcher for testing AR associations which allows
you to specify things like:
Foo.should have_many(:bars).through(:bazes)
I''m pretty darned proud of it and a couple of people have suggested
that I should submit it to the rspec_on_rails project. Before I go to
the trouble of writing out rdoc and fully spec''ing it, I just wanted
to make sure this was
2007 May 11
4
"validates_presence_of" not working
Hi, guys,
I''m learning to use Rails, and, while reading the "Rails: Up And
Running" book, I tried to make an insertion validation, using the
following code:
class Photo < ActiveRecord::Base
validates_presence_of :filename
end
It simply didn''t work, the validation does nothing and an insertion
with an empty field returns TRUE.
What''s wrong?
2007 Mar 29
21
a better "should have valid associations"
This is pretty much the same as last time around, if you recall.
Thanks to Wilson for converting to the new form. I''ve added a few
lines. Basically, it iterates over your model associations and does
two things.
- First, just try to call the association. Usually fixes speeling
erors or other such silliness.
- Second, try to find a record with an :include on the association.
This
2011 Sep 04
3
rspec assert inclusion in..
hello,
I would like to assert that an attribute of a model has value among
those in an array. How would I do it in rspec?
Something like this...
describe OptionType do
context "shoulda validations" do
it { assert_contains :type, [''Type1'', ''Type1'']}
end
end
2009 Apr 21
2
problem with sqlite3....
...med user by using the below command
-> ruby script/generate model user
so in db/migrate I got a file named 20090421211825_create_users.rb
created.
and in app/models : user.rb got created.
in user.rb.. i have written like this
class User < ActiveRecord::Base
validate_uniqueness :userid
validate_presence_of :username
end
in 20090421211825_create_users.rb, its like this
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.integer :userid
t.string :username, :limit => 32
t.timestamps
end
end
def self.down
drop_table :users
en...