Displaying 20 results from an estimated 10000 matches similar to: "polymorphic validation"
2006 Oct 11
1
Polymorphic Validations
Hi Everyone,
Ran into an interesting case last night, and I was hoping that someone
on the list here could give me some guidance.
I''ve got a Polymorphic association for Addresses (which can belong to
two different models).
The catch is, one model requires a strict, precise address, and the
other only requires a City, State and Postal Code.
I want to use :validates_presence_of :street,
2006 Apr 07
2
errors.add_to_base
What are the limitations on using:
errors.add_to_base
to display errors in views?
I have tried for days to add errors from my object.rb and they never get
displayed.
class Keyword < ActiveRecord::Base
validates_presence_of(:name, :message => "Name is required.")
validates_uniqueness_of(:name, :message => "This name is already in
use. Please try
2009 Jun 24
2
Boxplots: side-by-side
Dear R-sians..
I am trying to plot boxplots with side-by-side option.. I tried some of the
posted suggestions and could not make it work due to unequal sizes of
categories...
e.g.
weekly measured water depth values are categorized into 5 levels based on
their values
such measurement is again categorized into dichotomous levels - based on the
result of a test
I would like generate boxplot of
2006 Jul 16
6
How to access element attributes using RJS?
For example, in the following block:
page.select(''.foo'').each do |element|
...
end
How would I access, just for example, the id attribute of each element in
the collection?
I''ve randomly tried element.id and element.attributes[''id''], but neither of
those has worked. I''ve also been unsuccessful in finding any documentation
on this, but it
2016 Apr 22
2
Dial command for SIP driver with To-header config
Hello,
I'm using the following Dial command syntax:
Dial*(SIP/peer/exten!sip:xyz at xyz.com <sip%3Axyz at xyz.com>*), the SIP URI
after the '!' mark should be set as To-URI in outgoing INVITE
from Asterisk.
It works, but problem is that To-URI formatting is a bit messed up,
It looks as follows:
*sip:sip:xyz at xyz.com <sip%3Asip%3Axyz at xyz.com>*, it seems that Asterisk
2003 Jan 06
3
ipsec nat-traversal
It seems to me that ipsecnat tunnel type is not complete.
Latest drafts of ipsec nat-traversal use udp port 4500 for nat-traversal
communications. (It''s called port floating). That is needed to get rid
of ugly ipsec passthru devices.
Now ipsecnat opens port udp/500 from any source port.
And I think ipsecnat won''t work at all with gw zone defined? I''m not
sure about
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 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 Apr 05
4
validation on before_add callback
problem: validation error is not functionning in callback
callback for many-to-many association:
# keyword.rb
:before_add => :reject_self_related
def reject_self_related(related_keyword)
if (related_keyword == self)
# this does not work:
errors.add(:name, "Relating a keyword to itself is
forbidden!")
raise "Relating a keyword to itself is
2009 Jan 09
3
What is wrong with validates_presence_of :my_association ?
Category.has_many :products
Let''s say a product must belong to a category. I know it is recommended
to do the following:
class Product
validates_presence_of :category_id
end
But, as we all know, this is a pain for new records, meaning what if the
associated category is a new record?
I''ve been meaning to ask this, but what''s wrong with doing the
following:
class
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
2011 May 20
2
Variability plot in R
Is there a package in R that can do a variability plot?
A variability plot is a kind of categorized dot plot. (If there is a lot of data in each category, box plots are used rather than dot plots.)
Usually, the categories are factor level combinations. All the dot plots appear in the same window; below the x-axis a hierarchy of factors
shows which dot plot corresponds to which factor-level
2006 Mar 16
2
Verifying existance of related record
Is there an easy way to validate that a related record exists?
I''ve got a table that contains a set of categories and I want to make
sure the user has entered a vaild category (i.e. a category that exists
in the categories table). So in the model of the table I put this:
class Master < ActiveRecord::Base
belongs_to :category, :foreign_key => "categoryid"
2006 Jun 25
2
how to write the codes in view?(newbie question)
Hi.
I have two tables and want to join them.
<genres>
id
genre_name
genre_order
<links>
id
genre_id
name
symbol
url
order
display
etc
The code of links_Controller is like below.
def list
@links = Genre.find(:all,:include => :link)
end
Below is the mysql log.
SELECT genres.`id` AS t0_r0, genres.`genre_n
ame` AS t0_r1, genres.`genre_order` AS t0_r2, links.`id` AS t1_r0,
2010 May 25
2
Site Navigation With Polymorphic Has Many Through
Hi, seem to keep running into a wall here. I can''t find any resources on
site navigation that can deal with any model being in the nav, allow
nesting, and can dynamically update.
So I thought about it for a while, and decided on a MenuItems class, which
contained the position of the child in relation to it''s siblings, where the
parent and the child were polymorphic. Then a given
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
2011 Nov 02
4
undefined method `updated_at' for #<Classified:0x686c5e4>
HEllo, I have the following problem with rails, I am new in this...is
there anyone who explain to me what´s happens?
Thanks
See below:
NoMethodError in Classified#show
Showing app/views/classified/show.rhtml where line #17 raised:
undefined method `updated_at'' for #<Classified:0x686c5e4>
Extracted source (around line #17):
14:
15: <strong>Date Posted:</strong>
2006 Mar 14
7
Single form w/ relationships: how do I integrate it?
OK - I know this has been asked before, but I cannot find it in the
archives. Forgive me if I''m creating more noise than I should.
I want to know the easiest way to deal with this scenario:
I have articles. I have categories for the articles.
On the form where you write an article, there needs to be a free-form
field to entire the category.
The create() method will build the
2007 Aug 23
6
controller spec with model that validates_uniqueness
I want to use mocks and stubs to test the controller, but am having
trouble getting my validation not to trigger. Here''s the code:
# spec:
Image.stub!(:find).and_return(@image)
@image.should_receive(:save!).once.with(:any_args)
put :update, :id => @image.id, :category_id =>
@category.id, :image => {:name => ''test'', :image_number =>
2003 Nov 24
6
Proposal: 'global' package refactoring
Looking over the contents of various packages, including my own, it is clear
that lots of things end up 'hidden away' in packages where they don't
belong. My gregmisc package is a particularly egregious example, containing
something from almost every functional category.
I propose that from time to time the R community go through the complete set
of packages and 'refactor'