similar to: Setter that converts a float attribute to integer

Displaying 20 results from an estimated 2000 matches similar to: "Setter that converts a float attribute to integer"

2006 Jun 07
2
Problem with a setter that converts euros to cents
Hi, I have some problems with an application where I''m using custom accessors to do currency conversions. In my model, I have a price attribute in the database that stores the value in cents, to avoid future problems with float arithmetic and round. But at the views, I would like to show the price in euros, with decimal for the cents. So I defined a new attribute called price_in_euros,
2006 Jun 18
2
Hosting timezone differs of clients timezone
Hi, I have a website in production wich uses a lot of date and time calculations to show specific information. The timezone of my hosting service (Dreamhost) is PDT, and the timezone of my potential clients is CEST. There are 9 hours of difference between them. Is there an environment variable that I could adjust in my rails application, so all date/time values be set to CEST timezone? Thanks.
2005 Dec 23
10
Extending model
Hi, I''m looking for a way to extend one of my models to allow some level of abstraction between what goes into it and how it is stored. For example, say I have a Product and I want to set it''s price. A person using the website will type the price in euros. Internally, I''d like to store the price as an integer value of cents. I can currently do this with some ugly code
2006 Jun 13
2
Top margin on PDF generated with PDF::Writer
Hi, A little question. I''ve written a method that uses PDF::Writer to generate a PDF document with some images and text. This is the code on my controller: def pdf gen_pdf redirect_to("#{@request.relative_url_root}/pdf/cupones.pdf") end private def gen_pdf pdf = PDF::Writer.new(:paper => "A4") pdf.margins_cm(0) pdf.start_columns(2, 0) pdf.select_font
2008 Mar 24
1
Support for unparsed responses and json parser
This is my first message to the list. Hello everybody! I just wanted to let you know that I submitted a couple of patches for two features that you might find them of interest. The first one adds support for unparsed responses to Facebooker::Session and Facebooker::Service models. This allows to use the Facebooker::Session.post method to obtain a plain response from the Facebook API, useful for
2006 Jun 23
6
float calculation error
Hi I have the following values pActualCost = 33.00 pPaymentCost = 29.99 So this calculation should leave me with 0.01 pPaymentDifference = pActualCost - pPaymentCost however when doing this in rails, it returns 0.00999999999999801 has anyone got any suggestions to whats going wrong and how I can correct this Thanks Scott -- Posted via http://www.ruby-forum.com/.
2006 Apr 21
2
Using before_create and conflicting setter method...
Hi, I am having trouble using before_create when I have an specialized setter method: before_save :set_campaign_start #----------------------------------------------------------------------- ------- def set_campaign_start self.campaign_start = Time.now end # We want the date to always start at midnight
2013 Apr 22
0
setter method in rails 4 beta 1
I have a virtual attribute ''tags'' , and defined a setter method for it tags=(val). My setter method is not called while creating a Article. I copied my rails 3.2.11 code in rails 4, it was perfectly working in former. I want to know who can i use setter method for virtual attribute in rails 4. Or is it a bug in rails 4. I raised this as a issue in
2010 Apr 18
1
Getter and Setter with non DB property
Hi, I can''t find how do i created a getter and setter property for a non db property. what i have done isnt working, i have a cnt mass assign error. Here is what i''ve done: attr_accessor :creator_is_participant def creator_is_participant @participe end def creator_is_participant=(participe) if participe == true @participe = true else @participe
2006 Jun 01
1
Automatted Getter/Setter
Hey.. So I have a model that has a lot of number fields. Each of these go through a process when read in and read out to add/remove commas (between every three numbers) to make them more readable. The getter I currently have is like this: def sale_price Listing.insert_commas(read_attribte (:sale_price)) end and the setter is: def sale_price=(price) write_attribute(:saleprice,
2005 Dec 25
0
Setter not being called
I have written the followign setter to raise an exception when the field disabled_on is beeing assigned a value minor or equal that the enabled_on field. class Survey < ActiveRecord::Base def disabled_on=(date) raise AssignmentException if date != nil and date <= self.enabled_on write_attribute(:disabled_on, date) end end The matter is that this method never gets called, as I
2011 May 26
0
Reference Classes: getter and setter functions/methods and possible shortcuts
Hi everyone, just wanted to ask what's the smartest/recommended way of defining getter and setter function *shortcuts* (i.e. something like "[", "[<-") for Reference Class objects? Or is it desired to not use this stuff, but define methods like 'obj$getSubset(row=1:3, col=1)' and 'obj$setSubset(value=x)' instead? I have some example code that might
2004 May 27
3
"privileged slots"
Hi all, in the help for RClassUtils I found the expression "privileged slots" in function "checkSlotAssignment" with the explanation: /privileged slots (those that can only be set by accesor functions defined along with the class itself)/ I thought all slots of a (not private) class can be a accessed by a user via the @ Operator. Is there a way to make a single slot of a
2007 Jun 26
1
ActiveRecord: Attribute Setter for belongs_to relation attribute
Hi, I m trying to link into the process of setting an belongs_to attribute in my model. Unfortunetly, it does not seem to be as easy as for "normal" attributes. I ve tried the following: class Treatment < ActiveRecord::Base belongs_to :drug def drug=(new_value) ''my stuff super new_value end However, that does not work. Ive also tried self[:drug] =
2017 May 21
0
[PATCH 2/2] python: unicode decode handler error scheme setter
The set_decode_error_handler function allows the User to set the decoding error scheme to be used when non UTF8 characters are encountered in Python 3. The function has no effect in Python 2. Signed-off-by: Matteo Cafasso <noxdafox@gmail.com> --- generator/python.ml | 16 ++++++++++++++++ python/handle.c | 18 ++++++++++++++++-- python/t/test830RHBZ1406906.py |
2007 Dec 16
4
Make AR setter methods private?
Hi, I have a AR model that I want to limit changes to be only via instance methods that I''ve added. How do I prevent my other sw from setting the instance''s attributes? I know about #attr_protected and #attr_readonly. But the first leaves the individual setters as they were and the second stops all changes. I want something like "attr_private" Thoughts? Thanks,
2009 Aug 17
1
Problem with setter override on ActiveRecord
(This message was originally written on StackOverflow -- the formatting is much prettier there -- http://stackoverflow.com/questions/1283046/problem-with-setter-override-on-activerecord) This is not exactly a question, it''s rather a report on how I solved an issue with write_attribute when the attribute is an object, on Rails'' Active Record. I hope this can be useful to others
2006 Jul 19
5
Model Validation - with a twist
I''m stuck in a catch-22 type problem. I have an insert form for a table that uses the validation in the model. i.e. When you click submit on the form and haven''t filled in the required fields then you get the nice rails error messages saying "field can not be blank". This works fine until I introduce some more logic. What I''m trying to do is to validate
2006 Jun 28
3
how do I validate currency format if I am storing in cents?
Hi all - To avoid floating point issues, I''ve decided to store monetary values in cents in the database. However, the user will enter these in dollars and cents. Two questions: 1) How do I do the validation for the currency format? It looks like ActiveRecord truncates the cents since it thinks the field type is a Fixnum. Am I forced to do validation in the controller? 2) Where
2020 Apr 01
0
[PATCH v3 0/8] vhost: Reset batched descriptors on SET_VRING_BASE call
On 31.03.20 21:27, Eugenio P?rez wrote: > Vhost did not reset properly the batched descriptors on SET_VRING_BASE > event. Because of that, is possible to return an invalid descriptor to > the guest. > > This series ammend this, resetting them every time backend changes, and > creates a test to assert correct behavior. To do that, they need to > expose a new function in