Displaying 20 results from an estimated 10000 matches similar to: "How to get validates_presence_of worked in this situation?"
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;
2007 Jan 20
1
Not appear error message
I have a partial form "empresa". In new.rhtml of "empresa", I call the
partial form of "usuario". Well, it is happening the following: When
save empresa, and stop in validates, as much in "empresa" how much
"usuario", appear only error message of "empresa", and not of "usuario".
Because this happening?
ps1.: I use flash_message
2010 Jun 08
9
[Rails Heroku] Problem with saving object (on heroku hosting)
Hi All,
I have some strange problem which appears only on heroku hosting 2.3.5
default stack (not on my local computer)
I have some models. Here they are:
class Contact < ActiveRecord::Base
  belongs_to :user
  belongs_to :type, :class_name => "ContactType", :foreign_key =>
"type_id"
  validates_presence_of :name, :on => :create, :message =>
2012 Apr 05
0
Polymorphism, acts_as_relation gem and nested attributes
I have the following polymorphic association set up with
acts_as_relation (https://github.com/hzamani/acts_as_relation)
Model code:
    class Email < ActiveRecord::Base
      belongs_to :detail
      validates_presence_of :address
    end
    class Detail < ActiveRecord::Base
      acts_as_superclass
      has_many :emails
      accepts_nested_attributes_for :emails, allow_destroy: true
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 11
0
Easy Question, I Think
I am just getting started with Rails, don''t know any Ruby, and don''t
quite even get object oriented programming yet.  I have tweaked my
schema to The Rails Way and have generated a bit of scaffolding.
I am trying to create a new Part, which references a PartName and a
PartNumber.  I can create a PartNumber on the fly, but the PartName
has to exist.  I have an inelegant solution
2006 Jan 12
0
Easy Question, I Think [re-post, sorry if dupe]
I am just getting started with Rails, don''t know any Ruby, and don''t
quite even get object oriented programming yet.  I have tweaked my
schema to The Rails Way and have generated a bit of scaffolding.
I am trying to create a new Part, which references a PartName and a
PartNumber.  I can create a PartNumber on the fly, but the PartName
has to exist.  I have an inelegant solution
2009 Sep 21
0
Polymorphic form
I have two partials to deal with contact information. The Contact
information uses single-table polymorphism. I want to be able to use
save on Contact and set ''type'' manually, based on the type of form the
user is filling in. This is saved as the value on a hidden field.
class Contact
  belongs_to :person
  acts_as_list :scope => :person
  validates_presence_of  :type
 
2006 May 31
0
acts_as_blog
ActsAsBlog
==========
Here is a simple plugin to allow you to allow the use of
RedCloth,BlueCloth, or SmartyPants in your blog.
It''s super simple  to use.  It will take your blog post or comment and
transform it into html.
This allows you to write in a much simpler syntax and allows your users
to post valid html into their comment.
It  also allows you to block all html tags that
2007 Jan 23
0
validates_presence_of fields. in parent ok, but how in children?
i have the problem that my child class fileds aren''t validated on
saving the
parent. working with parent and child works without problems.
if all fields are filled correctly everything is saved as expected.
but missing fields in the child arent added to the errors.
following short sample shows what i try:
Model
-----------------------------------------------------
class Parent <
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 Jul 08
2
Creating/Saving dependent objects
Folks,
Am new to RoR and am building an example to get myself familiar. I am
running into a simple issue while creating a user registration page.
I have a User and Address models defined as below (partial/relevant code
included below). User has_one address and Address belongs_to user. I have a
foreign key defined in address table that refers to user(id)
In a form I take in username, password,
2006 May 24
0
Problems validating form with collection_select
I have the following models:
class Comandancia < ActiveRecord::Base
  has_many :elementos
end
class Elemento < ActiveRecord::Base
  belongs_to :comandancia
  validates_presence_of :nombre, :apellido_paterno, :apellido_materno,
:comandancia
end
In the view for New Elemento I''m using
<%= start_form_tag :action => ''create'' %>
  <%= render :partial =>
2007 May 19
3
form question
Suppose I have the following models/migrations:
class Car < ActiveRecord::Base
  belongs_to :manufacturer
  validates_presence_of :manufacturer
  validates_association :manufacturer
end
class CreateCars < ActiveRecord::Migration
  def self.up
    create_table cars do |t|
      t.column :name, :string
     t.column :manufacturer_id, :integer
  end
end
class Manufacturer <
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 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
2009 Jun 24
1
accepts_nested_attributes_for :reject_if issue
I have the following models:
class Order < ActiveRecord::Base
  belongs_to :billing_address
  belongs_to :shipping_address
  accepts_nested_attributes_for :billing_address
  accepts_nested_attributes_for :shipping_address, :reject_if => proc {
|attributes| attributes[''has_shipping_address''] != ''1'' }
  def after_initialize
    self.build_billing_address
2006 May 11
1
RoR completely ignoring a column when saving changes
I have an action that needs to update two models/two tables in one shot, 
and it works great, but ignores one column. Here is the action code: 
(verify_id is irrelevant in this case)
[CODE]
  def edit
    @page_title = "Edit User"
    @page_active_3 = "active"
    if request.post?
      @user = User.find(params[:id])
      @profile = @user.profile
      verify_id(@user.id,
2008 Apr 17
0
Having problem with validates_presence_of fields in form when trying to also use ActiveScaffold (x-posted at ActiveScaffold group)
I have an events listing site that includes the models Event and
DateAndTime, so an event that happens more than once (like a high
school play) can have more than one date_and_time. The Event model
has_many date_and_times, and the DateAndTime model belongs_to event.
The Event model validates_presence_of two submission form variables,
the_date and the_time, and those variable values then get used