similar to: How to restore fields ("validates_presence_of")

Displaying 20 results from an estimated 30000 matches similar to: "How to restore fields ("validates_presence_of")"

2006 Apr 19
1
validates_presence_of
Hi, having a few problems working out whats kicking off, im using validates_presence_of :title in a models class this seemed to work fine untill I used a custom new.rhtml error message I am gaining is NoMethodError in Recipe#create Showing app/views/recipe/new.rhtml where line #15 raised: You have a nil object when you didn''t expect it! You might have expected an instance of Array.
2006 Jul 13
1
error_messages_for
I can''t seem to figure out how to validate a few fields some1 please help me out model--------- class Record < ActiveRecord::Base validates_presence_of :sw, :flex end controller------------ class RecordController < A;;icationController def new @record = Rrecord.new @product = Product.find(params[''product_id'']) end def create
2007 Apr 10
7
Newbie :: Help !!! (database record compare)
Hi all, I''ve a two simple table, resource ======= resource.id resource.name resource.contact and project ====== project.id project.name project.resource_id (id from resource table) I want to display list of project that only belong to particular resource. my proj.rhtml is like ===================== . .. ... <h1>Projects</h1> <table border="1">
2005 Oct 12
4
Validating 2 related models at once not working
Hello, I have a form that submits data to two related models/tables. One is Customer the other is Address. Validation for Customer works fine but not for the Address. Class Customer < ActiveRecord::Base has_one :address validates_presence_of :login, :password, :email validates_associated :address end Class Address < ActiveRecord::Base belongs_to :customer validates_presence_of
2005 Jun 13
3
validations not working with collection population droplists
I have an ADD form with foreign key field values selectable via select list ( collection_select (...)). When I add validates_presence_of :someotherfield to my model for error trapping, I get the following error for each droplist: NoMethodError in Reviews#create_curriculum Showing /reviews/_form.rhtml where line #16 raised: undefined method `inject'' for nil:NilClass Extracted source
2007 Feb 26
2
boolean db fields set to false fail validation with validates_presence_of?
I have a model that contains a :boolean field. In my view, I have a simple select of Yes or No, which equates to true or false, respectively. If I choose yes and save, everything works great. If I choose no, my model fails validation as I have this set as a required field using validates_presence_of. I have checked the log and it''s definitely set to false, why would this fail validation?
2006 Mar 13
4
undefined method `validates_presence_of'' for #<ProductsContr
Hi, I am trying to use method `validates_presence_of'' for validating my input fields on form . I m using it in my action class as follows:- ======================= validates_presence_of(params[:product][:quantity]) ====================== But when I am running my application i m getting error like:- ========================= undefined method `validates_presence_of'' for
2006 Jul 12
5
validates_peresence_of
Is there an expert validater 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 <
2007 Dec 22
3
collection_select validation problem
I''m trying to assign a parent foreign key value using collection_select from my child "new" form. The problem I''m having is if I do not make a selection, I get the following error instead of the Rails validates_presence_of error: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occurred while evaluating
2006 Mar 07
6
Flickr - Tutorial
So I''ve pretty much followed the steps in the video tutorial on RoR.com for creating a small app, to search for photos on flickr.com - all is good, and works as intended to.. How would I go about adding validation, so if no tags are specified it will fail. I know I have to use validates_presence_of :tags - but not in the controller.. so I tried to generate a model called
2006 Jan 19
8
Passing variables across forms
I''ve been reading my Agile Dev book over and over again, but I can''t wrap my head around how to do this. There''s a question and answer portion site of my site. You begin the process by adding a question to the database. After that, the program should redirect you straight to adding an answer for that question. The problem is, I don''t know how to keep
2005 Dec 16
12
validates_presence_of not working
Hi, I''m new to ruby and rails. I just created a simple update page and the update works fine if all form fields are filled in. However there is one field that should never be allowed to be blank. So I put this in my model: class Topic < ActiveRecord::Base validates_presence_of :dr_title validates_length_of :dr_title, :minimum => 1 So, when I submit the form with a blank
2006 Jan 03
4
validates_presence_of *_id attributes
Hi all, I am a newbie to Rails. Please enlighten me on how to do this appropriately, the Rails and the Ruby way: Suppose I have a Recipe model. Let''s simplify things and pretend that it has only 2 attributes, a :name and the other is a ''category_id''. In the recipes table, category_id is a foreign key to field id of table categories. We also assume that I have generate
2006 May 18
1
Introspection of validates_presence_of
Hello all. I don''t know how to get all symbols passed to method validates_presence_of in model. I''ve trying to use following solution: class News < ActiveRecord::Base validates_presence_of :title, :text def validates_presence_of(*attr_names) @@obligatory_fields = attr_names ActiveRecord::Base.validates_presence_of(*attr_names) end def obligatory_fields
2006 May 22
2
Weirdness with validates_presence_of
Hi, I have a call to validates_presence_of in my model and it is behaving very strangely my first stab when this happened during testing was validates_presence_of :impact, :ease_to_implement if Proc.new { |record| !record.cost_estimate.nil? } I have three values in my model that I care about with this one. Basically what I''m trying to get to happen is if one is there they all must be
2006 Mar 25
3
validates_presence_of validation order?
I have a form with 3 fields: user_id, email and password. All 3 fields are required, so I have a "validates_presence_of :user_id, :email, :password" in my model. Works, but the validation errors show up in a different order than I specificed in the validates_presence_of statement. Is there a way to specify the order in which the validations (and corresponding error messages) should
2006 May 18
6
Newbie:problem when using validates*
Hi, I have performed the cookbook tutorial. Before tailoring the views and controllers, when I put in the model recipe.rb: validates_uniqueness_of :title validates_length_of :title, :within => 1...20 And I tried to introduce some new recipe without the above conditions I got the message: --------------------------------------------------- New recipe 1 error prohibited this category from
2005 Sep 19
1
help with has_one relationship??
Hi I''m new to Rails and I''m struggling with a ''has-one'' relationship. I''m trying to save product and image data in seperate tables with one to one relationship. I''m assuming the problem lies in the controller method below but can''t work it out. The models contain the has_one and belongs to statements, and I tried swapping these
2006 Aug 10
4
I need "validates_presence_of" help
Hi - I have 3 fileds a user can fill out. They can fill out 2 of them or just one of them, for example. fill out these 2 fields: Field1 and Field2 Or fill out this field: Field3 In my model how do I use validates_presence_of for Field1 and Field2 or just Field3. I want to do something like this: validates_presence_of Field1, Field2 OR validates_presence_of Field3 So the user can fill out
2006 Feb 08
1
Weird validation issue
Hi, I''m having a weird validation issue. Validation isn''t working for certain attributes and, for some reason, it''s also affecting things outside of validation. For campers on certain camp types, we require some information about their school. I tried to validate the information this way: validates_presence_of :school_type, :if => Proc.new { |c| !c.booking.nil?