Displaying 20 results from an estimated 6000 matches similar to: "Verifying existance of related record"
2006 Apr 07
6
validation nightmare
Please help, I am really at a loss at how validation is supposed to work
in rails.
Model contains
acts_as_tree
I want to force my NEW objects to have a parent
I do NOT want existing object to have a parent
so I only want to have parent_id on create, NOT on update.
I am trying this:
def validate_on_create
validates_presence_of :parent_id, :message => "You must specify a
2006 May 04
2
validates :on 2
Hello, I need to have this for :create and :login how do I do so
validates_presence_of :login, :password, :password_confirmation,
:user_name, :email, :on => :create
I do need it to be off in a number of places though
--
Posted via http://www.ruby-forum.com/.
2009 Feb 19
3
Associated child records not created on creation of a parent.
I am trying to create a record with association. Within the create
method, I would also like to pre-populate dependent (has_many) records
from a template in the database.
The child records are <u>mysteriously rolled back </u> if I insert
them in a loop. If I try to insert a single child record, it works.I
have read the books and tried to google my way out of this but am at a
dead
2005 Sep 27
2
No Custom Validation
Hi,
Correct me if I am wrong but there doesn''t seem to be an easy way to add
validation outside the pre-built ones (validates_presence_of,
validates_lenght_of, etc.).
Ideally there should be something like:
Class Person < ActiveRecord::Base
validates :my_method, :on => create, :message => ''was not valid''
def my_method(param)
false unless
2006 Mar 15
3
Self-referential join model does not work
I have been trying to model a labeled graph using ActiveRecord (trunk
version). Basically, I have a ''Node'' model which represents a node linking
to other nodes. Links (aka edges) are labeled (i.e., have a ''label''
attribute and other behavior). Thus I decided to model edges as an ''Edge''
model and use a ''has_many :trough''
2006 May 23
1
Validating a required relationship.
Hello,
I''m not sure if I''m missing something blindingly obvious here.
All the relationships that Rails comes with assume 0..n, yes? It''s
not a strict 1 to 1 or 1 to n because it''s optional. My question is
this -
What is the best way to implement a required relationship?
For example, if I require that a comment is made by a user (a user
has many
2006 Oct 14
2
issues with validates_associated not throwing error
Hello all
I''m having an issue with ruby on rails, and it not throwing an error
where it should.
I have a class ''clientpool'' that is:
class Clientpool < ActiveRecord::Base
set_table_name "clientpool"
set_primary_key "id"
belongs_to :clients, :foreign_key => "cliname"
validates_presence_of :cliname
validates_associated :client
end
2005 Dec 02
8
UserEngine: stack level too deep
Hi,
I''m trying to get the UserEngine running.
I have installed the LoginEngine, added the essential lines to
environment.rb / application.rb and application_helper.rb.
Worked fine.
Then I did the same with the UserEngine and when trying to set up the
db:
rake engine_migrate ENGINE=user
I get:
Migrating engine ''user_engine''
rake aborted!
stack level too deep
But...
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 25
2
Authentication design/ideas
Hi all,
I''m using acts_as_authenticated for the front end facing part of my
site. I have a model called Customer. I now want to protect the admin
sides of things. I am thinking of using Ezra''s acl plugin
(http://opensvn.csie.org/ezra/rails/plugins/dev/acl_system2/README)
for this. My only problem is that I don''t want the model for admin
users to be called Customer,
2007 Dec 18
2
Active Resource and non default model names
I have a model (accessed restfully) named TranscoderQueue, it''s name
is overridden to ''TransocderQueue'' so it is accessed as ''/
transocder_queue'' as opposed to ''/transocder_qeueus''.
class TranscoderQueue < ActiveRecord::Base
belongs_to :campaign, :class_name => "Campaign", :foreign_key =>
"campaign_id"
2006 May 24
4
AR foreign key problem.
Hello Railslist,
(I''m using RadRails 0.6.3 on Windows XP with Ruby 1.8.4, Rails 1.1 and SQLite3)
I have two tables in the database: "locations" and "customers":
customers.sql
---
id INT PRIMARY KEY
name VARCHAR 255
address VARCHAR 255
postal_code VARCHAR 255
city VARCHAR 255
---
locations.sql
---
id INT PRIMARY KEY
postal_code TEXT
longitude FLOAT
latitude FLOAT
2006 Dec 11
2
Custom Validator
I want to add a custom validator in one of Model. For example Rails has
inbuilt validation methods like validates_uniqueness_of,
validates_presence_of . What I need is a similar kind of method
(example: validates_line_items), that can run my custom code while
saving, updating the record and can add custom error messages to the
record. Please help me by suggesting how i can do this.
--
Posted via
2005 Aug 19
2
data validation
I''m trying validate date before they''re stored into the DB, but it seems,
validation doesn''t work..
my model looks like this:
class Company < ActiveRecord::Base
has_many :contacts,
:foreign_key =>''company_id''
has_and_belongs_to_many :categories, :join_table => ''company_to_category'',
:foreign_key =>
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 =>
2009 Mar 08
2
RESTful nested resources and polymorphism?
With ref to my previous post: http://www.ruby-forum.com/topic/180356
I am now able to access items from topics controller. However, now I
need to add sub-item e.g.: An item itself could have many sub-items. So
my items model is like:
class Item < ActiveRecord::Base
validates_uniqueness_of :title, :scope => [:topic_id]
validates_presence_of :topic_id, :title, :owner, :position
2011 Apr 28
3
difference between validate and validate_on_create
i just ran into a problem with some test, and i am not exactly sure why,
but the difference happened when i changed my model validation from:
validate :custom_validation
to:
validate_on_create :custom_validation
can someone give me any ideas on where in the chain the validation takes
place?
thanks!
--
Posted via http://www.ruby-forum.com/.
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
2008 Sep 01
3
basics questions on rails
Hello,
I started to use rails few weeks ago, and I have got basic question
about it.
1. There is a way to keep my form filled, after submit it (for example
if I get errors) ?
2. I would like to create a ''tree'' with my datas like ''pages'' for
example : a page has one children and belongs to a page. I added has_one
and belongs_to to the model but it
2006 Aug 14
2
after_create is not being called
Hi all
I have the following model:
class PhotoGallery < ActiveRecord::Base
attr_accessible :title, :description, :file_path, :title_photo_id
has_many :photos, :dependent => :destroy
belongs_to :title_photo,
:class_name => ''Photo'',
:foreign_key => ''title_photo_id''
validates_presence_of :title, :description, :file_path