Displaying 20 results from an estimated 10000 matches similar to: "Strict STI?"
2006 Aug 09
6
How to change the error message easy way
validates_presence_of :fname
results in the error message
"Fname can''t be blank".
What I want is "First Name can''t be blank".
I could do this
def validate
errors.add_to_base("First Name can''t be blank") if fname.blank?
end
I find this clunky and I have to put everyrhing in the validate method. Is
there an easy to get what I want.
I
2006 Jul 26
4
Execute code when an inheritance happens, or disabling STI
I am trying to inherit from a ActiveRecord class defined in a plugin.
The problem is that ActiveRecord thinks I am doing an STI and is looking
up a table that doesn''t exist.
Currently, I have a method in the parent class that looks like this:
def self.fix_table_name
class_eval do
set_table_name(Inflector.tableize(self.to_s))
end
end
The problem is that this method
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 Oct 10
5
oddness when adding to index -
I was having some odd results when working with acts_as_ferret (current
trunk), so I decided to test with the current version of ferret to see
if I encountered the same problem. I did. Here are the details:
installed ferret 0.10.10 on debian sarge with ''sudo gem install ferret''
(btw, same results on OSX)
opened up an irb session:
irb(main):001:0> require
2006 Apr 01
4
Custom Validations
Does anyone how to create a validation that:
validates_presence_of :a OR :b
I.e. :a OR :b must be present.
I thought this would probably be possible with some kind of validation
callback, e.g.:
def check_a_or_b_is_set
return (a or b)
end
Any ideas?
Thanks,
Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2010 Apr 18
1
Comparing data frames
Dear very helpful friends,
It is Sunday, there is no air traffic in Europe, what better to do
than try and learn me some more R.
I have the following example:
owner <- c(1:4)
animal <- c("cat", "dog", "cat", "dog")
char.1 <- c("fluffy", "playful", "mean", "stupid")
food <- c("cat food",
2006 Jan 10
5
Noob ActiveRecord Join Question
I''m new to rails and ruby, and after trying to get this to work
correctly for hours, I thought I''d give this forum an try.
I''ve setup a trivial project just to mess around with Rails database
naming conventions and associations.
I''ve got a table called Pets, and a table called Types.
Pets contains a list of pets, Parky the cat, Daisy the dog, etc, And
Types
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
2007 Sep 29
8
Inheritance problem in model
Hello,
I''ve got a problem with the inheritance as soon as I try to use it in a
model.
I''ve got plenty of items which can share a lot of code, so I created a
class "Item", which inherits from ActiveRecord::Base, but because it''s
not a "real item" but an interface, I set it abstract (writing
abstract_class? method).
Then I have all the differents
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
2012 Jan 27
1
Horizontal stacked 100% bars with ggplot2
Hello, R friends,
I'm trying to crack this nut:
Example Data.
pet gender
dog male
dog female
dog male
cat female
cat female
cat male
Plot Task.
Horizontal 100% bars where
y axis shows gender factor (male vs. female)
and x axis shows percentage of kind of pets (dog vs. cat)
so that % dogs + % cats are stacked in 1 bar and sum up to 100% (for each gender group 1
2006 Nov 16
1
Strange indexing issues with CachedModel, STI, and AAF
I started using robotcoop''s CachedModel class in my project but have encountered problems when using it with the acts_as_ferret plugin. It seems it doesn''t index everything in my STI model, also if I do a search from my base STI class I get a result count but no results. If I run the same search from one of the children STI models I get the appropriate results (if the information
2008 Dec 18
1
inserting zero instances with zeroes in a matrix
Hi all,
Suppose I had the below example where a survey was carried out recording the number of each type of pet in each house
count<-c(2,1,2,1,2,3,4)
house<-c("house1","house1","house2","house3","house4","house4","house4")
2006 Jul 12
1
validate method not getting called?
Here''s a snippet of my model:
validates_presence_of :from_name, :from_email, :reply_name,
:reply_email, :eSubject
protected
def validate
puts "Calling: #{target_list_ids}"
errors.add_to_base("You must choose at least one target list for
this job") if self.target_list_ids.nil?
end
It appears that the validates_presence_of are being called just fine,
2010 Feb 03
4
customizing validation msg
Hi,
i am using the default validation of RoR how i will customize them i
dont want to display the default message but i want to print the
message i want like for city_id the default message is "City can''t be
blank" i want this message as "Please enter city"
Regards
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2006 Nov 21
5
acts_as_ferret with STI models
Can acts_as_ferret search only one of the inherit models in the
hierarchy of STI models? Say you have Contents, with types articles and
comments. I know that you do Contents.find_by_contents, but can you
also create indexed for Comment and Articles?
Thanks for you help
Miguel
--
Posted via http://www.ruby-forum.com/.
2006 Jul 05
2
Serialized object behaves weird
Hi!
I got a class named EinsatzFilter which I serialized to session. Before
saving to session it works afterwards I keep getting the message:
"undefined method `to_s'' for #<Person:0x38c6ab8>". "Person" is a from
ActiveRecord::Base inherited class.
Code:
class EinsatzFilter
include ApplicationHelper
attr_reader :personen, :monat, :projekte, :kunde
2008 Dec 09
7
subclassing vs mixins, which one should be used?
Hey all,
I have two models in my rails project that share a lot of traits. They
each have the same 4 properties, and now I need to add 2-3 methods to
each one that will be the same. In the spirit of DRY I am looking for
a solution to write these methods only once.
Both of these models already inherit from ActiveRecord . . . and I
didn''t know if it was safe to just "whip up" a
2009 Apr 02
3
error_messages_for does not display the error
Hi all
I''ve approached Rails since a couple of months to develop a quick
application for my company. Fantastic framework. As every noob, I do
have some gaps to cover. The one which is giving me a little
frustration, generated by my lack of knowledge is as follows.
I need to make sure the region object is not deleted if there are
countries associated with it. I solved this by putting a
2008 May 13
2
[LLVMdev] Python bindings available.
Hm. I may misunderstand, but I'm not sure that's an improvement over
the problem you're trying to solve. How about something like this?
(Please forgive any accent; I don't speak snake fluently.)
class Pet(object):
@staticmethod
def new():
# Create a 'free' pet. It can later become owned, but not to more
than one owner.
return