similar to: Using Aggregations in HTML forms?

Displaying 20 results from an estimated 6000 matches similar to: "Using Aggregations in HTML forms?"

2006 Jul 22
3
refactoring commonly used aggregations
I have a number of models that use an aggregation to combine First Name, Middle Initial and Last Name and they have been working fine. I am looking to clean this up, DRY it if possible. I have things like this in application.rb class Clwholename attr_reader :first_name, :middle_initial, :last_name def initialize(first_name, middle_initial, last_name) @first_name = first_name
2005 Dec 16
4
Validation with Aggregation
ActiveRecord supports composed_of for value objects which is fantastic but one thing that it doesn''t seem to support (or at least I am unable to find any documentation for) validation of the value objects. For example, given the following: class Message < ActiveRecord::Base composed_of :sender, :class_name => ''EmailAddress'' composed_of :recipient,
2005 Dec 17
1
How to use validation with aggregation (composed_of)?
At the risk of being banned for posting the same question twice, I thought I''d try once more with a question for the title rather than a statement (on the basis that perhaps questions get answered and statements ignored ;-) ) ActiveRecord supports composed_of for value objects which is fantastic but one thing that it doesn''t seem to support (or at least I am unable to
2009 Jan 16
1
Aggregation: problem with uninitialized composed_of object
Hi, I''m getting this error: >> p = Plan.new >> p.amount TypeError: wrong argument type String (expected Fixnum) Apparently this happens because the aggregation isn''t initialized. Here''s the code: class Plan < ActiveRecord::Base composed_of :amount, :class_name => "Money", :converter => Proc.new { |s|
2006 Jul 13
1
Incorrect composed_of I think
I am trying to use composed_of in my model, but I not succeeding. With the code I pasted below, I cannot perform this action in the console: property = Property.new(1, "px") I get NameError: uninitialized constant Property when I try to perform that action. It''s not finding my class I made I suppose. The Property class is in the same file as the Element class, element.rb.
2009 Nov 18
2
Composing Data from THREE models with Aggregation
Hello! I''m looking for assistance EXTENDING an example from the Agile Web Development With Rails book: Composing Data with Aggregation (page 324). I''m trying to map three columns to a single Ruby object. However, unlike the example in the Agile Web Development book, the three columns I want to map into one object come from THREE DIFFERENT models. I want to map the following
2006 Mar 19
4
Trouble with composed_of
I''m trying to use composed_of within my model. I have a field in my database named ''card1'', which is simply a string. I have this in my model class Player < ActiveRecord::Base composed_of :card1, :class_name => ''Card'' end class Card attr_reader :value, :suit def initialize(s) @value = s[0].chr @suit = s[1].chr end end The
2006 Jul 23
0
composed_of and validates_presence_of
I''m using composed_of in one of my models, and I''d like to validate that the attribute is present. class Hand < AR::Base composed_of :level, :mapping => [ %w(sb sb), %w(bb bb), %w(ante ante) ] validates_presence_of :level, :message => "must be set" end The Level class itself is very simple: class Level include Reloadable attr_reader :sb, :bb, :ante
2009 Feb 26
1
composed_of, aggregate object isn't saved
I am relatively new to rails and I cannot figure out what is going on here. I am using the composed_of method in an ActiveRecord class to create two aggregate properties: shipping_address and billing_address. The object properties are getting populated from the form and validation is working - no problem. When I call order.save, though, everything is being saved except the address fields. I am not
2006 Mar 03
0
unused composed_of bits
I implemented a Temperature model for my application. It is pretty basic, composed of a temperature, a unit and some conversion methods. In my app model I decided to store temperature values in Fahrenheit, so there is no need to remember the units between invocations. I am having a little trouble composing my app model. A little bit of my temperature class: class Temperature # Composed of
2006 Mar 09
1
[TIP] Making an intelligent form fields
After searching arround I found a quite smart solution to me for binding form fields to model in an active way. I use aggregations with single value objects such as class Percentage attr_accessor :value def initialize(value) @value = (value.is_a? String) ? value.tr('' %'', '''').to_f : value end def to_s return unless value
2006 May 18
1
Patch 5091
Hi, I submitted a patch (for the first time) a couple of days ago (http://dev.rubyonrails.org/ticket/5091 - the decsription is included below). I''ve noticed some posts to rails-core notifying the world of patches, since there''s been no activity on said patch I thought I''d do the same. Please let me know if this breaks protocol. Cheers, Ian White --- patch summary
2008 Feb 25
1
NoMethodError: undefined method `<=>' for :zip:Symbol
Long time programmer, but I just started learning RoR last week. I am going through some examples in the book "Ruby on Rails: Up and Running". The example I am on had me add a table to the database that looks like so: CREATE TABLE people ( `id` int(11) NOT NULL auto_increment, `type` varchar(20) default NULL, `name` varchar(20) default NULL, `email` varchar(30) default NULL,
2006 Feb 26
2
auto_complete on steroids
I am trying to get more out of auto_complete than it apparently was designed to deliver. My problems seem to be two fold. 1 - I use aggregations on names... :first_name, :middle_initial, :last_name and then aggregate them using a composed_of :wholename thing auto_complete_for seems to be wired to only use table columns directly and gags on the aggregate form. 2 - foreign table columns -
2008 Jul 07
0
ActiveRecord in Rails 2.1.0 misbehaving for Aggregate Attr.
I am not sure if this is a bug in ActiveRecord or is this the intended behavior. If it is then it does not make sense to me. In a nutshell: If you change an aggregate object attribute created via composed_of method (see Agile Web Development - Second Edition Chapter 17 page 313 onwards) and then save the model, the change to the model (composite attribute specifically) will not be saved UNLESS
2007 Mar 28
1
rsync patch -flags fails to compile on Mac OSX
I am trying to compile rsync 3.0.0cvs with the flags.diff patch on a Mac OSX G4. It fails because the flags UF_NOUNLINK, and SF_NOUNLINK do not exist on this platform. sys/stat.h only gives the following flags * Definitions of flags stored in file flags word. * * Super-user and owner changeable flags. */ #define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */ #define
2006 Jul 11
1
Validating composed_of
Hi, How do I validate a composed_of attribute in my model? I have a product model with: composed_of :price, :class_name => ''Money'', :mapping => %w(cents cents) This maps the price attribute to the Money (http://dist.leetsoft.com/api/money/) class. I want to make sure that the price only contains a price to 2 decimal places i.e. 1.25. This is because if someone enters
2006 Jan 30
1
Introduction & time_zone_select with mapped TimeZone question
I''m new to this list, I''m a student in History, Computerscience and a bit of Philosophy from the Netherlands... I have started using rails a few weeks ago, I did read the Agile Webdevelopment with Rails book, and I generally started to love Rails for it''s sheer beauty and intelligent structure... However I came across something that puzzles me quite a bit. It''s
2008 Dec 01
0
more friendly "dtrace --actions" , "dtrace --aggregations", "dtrace --varib
To remember all dtrace actions, aggregations and variables is a headache, even worse, they are not include in dtrace(1M) now. So here is a chance to have a CLI RFE - to have something like "dtrace --actions", which will list all actions, like this page: http://developers.sun.com/solaris/articles/dtrace_quickref/dtrace_functions.html "dtrace --aggregations", lists all
2006 Jan 22
0
Validation on composed_of problem
I am having problems with this: validates_presence_of :amount validates_format_of :amount, :with => Money::PATTERN, :allow_nil => true composed_of :amount, :class_name => Money, :mapping => [[:amount, :to_s]] The problem is when I use this field in a form, and the text is blank, ActiveRecord gives me two errors: "money is invalid" "money