Displaying 20 results from an estimated 6000 matches similar to: "Money library usage?"
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 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
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
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,
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 Jun 17
5
STI versus Composition...or the headaches of one big table
Guys,
I have a relationship between model classes that I believe is best  
represented by inheritance, but the likelihood that things will change  
often is driving us to composition instead.
So, I have a class called Autos, and subclasses called Suvs, Minis,  
Mids, Sports, for example.
We have been requested to avoid the STI approach to this, because of  
fear of a quickly growing table with
2006 Mar 18
1
rails-y way to handle quasi-numeric type
I have a class called Duration that represents a unit of time. It has lots
of time-related methods and an attribute that represents the duration in
seconds.
I want to store it in my db.  I had a column type of NUMERIC, so if i save
it, rails trys to coerce it to a float automagically and fails.
I need to display it and store it as a number but treat it in the middle
layer as a Duration so I can
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 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 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 Jan 23
1
Making Parents object attributes available
Hello,
I have a class Person
class Persoon < ActiveRecord::Base
   set_table_name "Persoon"
   set_primary_key "p_persoon"
   has_many :adres, :class_name => "Adres"
   composed_of :name, :class_name => Name, :mapping => [ [:naam,:naam],
[:voornaam,:voornaam], [:voornaam2,:voornaam2],
[:persnickname,:persnickname], [:perssortname,:perssortname] ]
  def
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
   
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
  ...
2006 Sep 08
1
has_many relationship extensions and scoping rules
Hi all !
Is this supposed to work ?
class Email < ActiveRecord::Base
  has_many :to, :class_name => 'Recipient', :conditions =>
"recipients.source = 'to'" do
    def create!(*args)
      with_scope(:create => {:source => 'to'}) do
        super
      end
    end
    def build(*args)
      with_scope(:create => {:source => 'to'}) do
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 Mar 07
13
Active Record - Can''t figure out relationship.
I have the following two tables:
create table teams (
 id             int             not null auto_increment,
 short_name     varchar(12)     not null,
 long_name      varchar(50)     not null,
 logo           varchar(20)     not null,
 primary key (id)
);
create table rounds (
 id             int             not null auto_increment,
 home_team_id   int             not null,
 away_team_id   int
2007 May 17
4
How to mock helpers in view specs ?
Hi all,
I am mocking the following Rails view (inside a partial):
<%= render :partial => "forums/forum",
    :collection => forum_category.forums.readable_by(current_user? ?
current_user : nil) %>
My spec fails with the following message:
1)
ActionView::TemplateError in ''forum_categories/index (anonymous user)
should only render forums accessible to anonymous
2005 Dec 07
5
InPlaceEditor update of page contents ?
Hi all !
InPlaceEditor refreshes only the element that was updated.  Is there
any way to make it update tons of other stuff ?
I have a table where changing a value in it causes changes in most
other cells (weight to percentage to money).
Thanks for any help !
--
François Beausoleil
http://blog.teksol.info/
_______________________________________________
Rails-spinoffs mailing list
2006 Jul 26
2
ResponseLogger Plugin
http://www.agilewebdevelopment.com/plugins/responselogger
From the README:
Ever wondered what exactly Rails returned in an RJS response ?  Here''s
your chance to see it:
  ===> text/javascript (49 bytes)
  Element.replace(''target'', ''<em>It works!</em>'');
  <===
== ResponseLogger
Logging the response value is easy.  Simply install
2006 Mar 10
2
adding to has_many on create and edit
Hello,
I am fairly new to RoR and I have a question I hope can be solved  
elegantly (so many things are, so why not this one too?).  I have a  
working solution, but I want to be sure I am doing things the "rails  
way" (having come from PHP).  You could say I am looking for a little  
validation (no flames please).
I have a table of units like so:
CREATE TABLE `units` (
   `id`