similar to: Validating composed_of

Displaying 20 results from an estimated 1000 matches similar to: "Validating composed_of"

2006 Jun 25
1
Money library usage?
Hi, I''m obviously doing something stupid, but I''m trying to figure out how the Money library (http://dist.leetsoft.com/api/money/) is supposed to work. I have a Product model and I want to have an attribute in my model called "price" and I want it to accept Money objects. So I have this in my Product model. class Product < ActiveRecord::Base composed_of :price,
2006 Apr 21
10
Paypal payments and IPN
I have followed the instructions over at http://dist.leetsoft.com/api/paypal/ In order I: 1. installed the money library with gem install --source http://dist.leetsoft.com/api/paypal/ money 2. installed the paypal library with gem install --source http://dist.leetsoft.com/api/paypal/ paypal 3. created a new app with rails NewApp 4. added the PaymentHelper module to the
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 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 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.
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
2006 Jul 25
7
Paypal - Instant Payment Notifications
Has anyone any experience of getting the Paypal plug in to work? I''ve set myself up on the Paypal sandbox, I''ve setup my sending and receiving accounts, i''ve got the Paypal button on my view, I can go and make payments ok, but I can''t get the Instant Payment Notification part to work. At the end of the payment process the user is left in a paypal screen
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 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 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
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 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,
2006 Jul 28
15
Store/product stock design question
Hi all, I''m having trouble figuring out how to handle stock levels in a new store I''m building. When products are entered into the admin of the store, they have a stock number associated with them. What I''m not sure about, is how I go about maintaining this stock level. Take this scenario: 1. User A adds an item to their cart, and I check that it''s in stock -
2006 Aug 14
1
What fields_for really for?
Hello everyone! I have 3 models: === 1 === class Region < ActiveRecord::Base has_many :districts end === 2 === class District < ActiveRecord::Base belongs_to :region has_many :suburbs end === 3 === class Suburb < ActiveRecord::Base belongs_to :district validates_numericality_of :region_id, :only_integer => true end In edit.rhtml for SuburbController I need to specify
2006 Mar 16
5
TimeZone, TZInfo, daylight savings, and composed_of
Does anyone know the best way to track time zone information. There doesn''t seem to be much documentation on this. So far it seems like a simple db field like create table accounts ( id int unsigned not null auto_increment, name varchar(50) not null, time_zone varchar(50) not null, ... primary key (id) ) and a class like class Account < AR ...
2007 May 01
2
Problem validating boolean
Hi I''ve got a problem validating a boolean and I can''t see what the problem is. Here''s my model: class FinanceAgreement < ActiveRecord::Base belongs_to :asset validates_presence_of :finance_company validates_inclusion_of :balance, :in => 0.01..10_000_000 validates_inclusion_of :term, :in => 1..600 validates_numericality_of
2006 Mar 23
5
Filecolumn storage location
Hi, I am using file_column for some image uploading. I want to have all the images stored under one root which I have managed by setting the :store_dir option as below. file_column :filename, :store_dir => File.join(RAILS_ROOT, ''public'', ''images'', ''products'') So, my images get uploaded to: /public/images/products/<primary_key>
2006 Feb 28
12
Examples for Money library ?
Can anybody share some examples of their Money implementation ? I''m trying to setup a Model to use this library, but can''t seem to wrap my head around how it is exactly supposed to work. My Model (Foo) looks like: =============== composed_of :commission, :class_name => "Money", :mapping => [ %w(commission_cents cents), %w(commission_currency currency) ] Yet, in
2010 Jan 25
4
Does Amazon.com blocks scraping?
Hi there Does anyone know if Amazon.com has any sort of server side script that tries to block scraping activities? I first noticed that if I didn?t change the agent alias, it would fetch a page exactly like the normal one, but without the intial search field(maybe a silly way to prevent scraping). Then after it, I changed to some other alias, and submit a search. I got the result page as
2006 Jun 07
1
Validating numericality based on related attribute value?
I have a price attribute in my model which I need to validate as a positive number if the attribute price_terms.requires_value is equal to ''Y'', otherwise price can be blank or zero. Price_terms is a select list which my model table belongs_to. How do I do this? - I tried doing this: validates_numericality_of :price, :if => self.price_term.requires_value.upcase ==