Displaying 20 results from an estimated 5000 matches similar to: "slightly OT - Ruby division"
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
2005 Nov 21
10
Anybody using SCGI in production?
Or does anybody prefer fastcgi/fcgi? I''m using webrick for development, but plan on using scgi
when I switch to production (because it appears to be an update to fastcgi, and I couldn''t get
fastcgi working anyhow).
thanks
csn
__________________________________
Yahoo! Mail - PC Magazine Editors'' Choice 2005
http://mail.yahoo.com
2006 Apr 02
16
12 / 16 = 0
Hi,
Just thought it was weird that Ruby doesn''t automatically cast ints to
floats. Seems so un-rubyish
irb(main):006:0> 12/16
=> 0
irb(main):007:0> 12.to_f / 16.to_f
=> 0.75
Jeroen
2005 Nov 01
1
not updating non-changed fields
Hey all,
this is kind of a weird question, but is there any way to tell ActiveRecord
to not update a field that hasn''t been changed? When I see my executed
UPDATE sql, I see it trying to update every single field, regardless of
whether its been changed or not. Is there any way to have ActiveRecord
update ONLY the changed fields?
Thanks guys,
Jin
2006 Jul 17
4
Division not working!?!??
I guess you could call this a noobie problem as well. I''m trying to
divide two numbers by each other...
For example:
<% for element in project.elements %>
Element: <%= horizontal_bar_graph [element.name,
((element.completed_hours / element.hours) * 100)] %><br />
<% end %>
element.completed_hours == 2
element.hours == 5
(2 / 5) * 100 == 40
However,
2006 May 04
1
ruby.exe growing large, possible memory leak in sql server
Hey all,
I believe there is a memory leak when using Win2000 + SQL Server +
Apache2 + scgi + rails 1.1. My apps so far have been pretty ''low
impact'' and i did not notice it before, but the memory footprint of
ruby.exe is growing larger. After 6 queries that fetch ~2,000 rows
each, ruby.exe has grown to 41 megs (originally around 20). The memory
leak is also present in webrick,
2005 Nov 02
4
acts_as_metadata?
I''m running into the need (on at least one project now) to implement
end-user-customizable "metadata" or properties on model objects. The
standard example would be a Person class that had first_name,
last_name, etc. but would need to be extended real-time (through the
web admin interface) with properties such as phone_number : varchar
(30). I''ve done some basic
2005 Dec 15
5
site takes a while to load after first visit in a while
Using lighttpd + fcgi to power a site. When no one has accessed it in
a while, the first visit to the page takes a while to load up. Then
subsequent visits are fairly fast.
Any ideas on how to fix it?
2005 Apr 01
11
I want to blog!
This isn''t Rails or Ruby related, but I just need some advice and
thought I''d ask the bright individuals here. I want to start my own
blog but I''m not sure where to begin. I don''t want to get a blogger
account because I want to have my own domain. Blogger also doesn''t
have many features. My hosting service is 1AND1 so it supports php,
cgi and mysql.
2005 Dec 15
7
PHP include() Type Functionality in Ruby/Rails
Greetings,
I am working on extending a new part of our site to use Ruby on
Rails, and have several portions of the site that is included in
external files. The rest of the site is built on top of MovableType
and uses PHP Includes to reference the external files.
Is there similar functionality in Ruby or Rails that I can use so I
don''t have to update excess content in two
2006 Jan 30
3
general questions
Agile book lacks some basic information, perhaps I need to learn ruby as
I am lacking information - some basic things - especially debugging.
The following are stupid newbie questions and any portion of them
answered would be great.
1. If I am viewing a page from app/views/clients/ and on this page, I
want to put a ''link_to'' directive to say app/views/case_managers...
how do I
2005 Nov 16
37
Postgresql vs MySQL
Is there any reason to avoid using postgresql for small web apps? That is, is it''s
overhead so large that the lighter MySQL will work substantially better for small apps on
small machines? Or are they very similar in performance and configuration?
I''ve used MySQL but postgresql has its appeals and I''m wondering if I need to keep MySQL
around at all.
On the other
2015 Sep 10
3
[OpenCL] Implicit arithmetic conversion of INT_MIN to int vector type
Hello,
I recently came across an OpenCL kernel in which an int vector type was subtracted from the INT_MIN constant, e.g.
int2 v2 = INT_MIN - (int2)(0);
INT_MIN was defined as
#define INT_MIN (-2147483648)
Clang in OpenCL modes (-x cl) produces the following error:
vector_conversion.c:12:42: error: can't convert between vector values of different size ('long' and 'int2'
2005 Dec 29
3
Maintaining DB reflection without scaffolding
Hi,
I would like to know if there is a way to maintain database reflection
for the ''new'' and ''edit'' views whilst removing scaffolding?
I''m trying to create a webapp that will be somewhat maintainable by
colleagues (that aren''t necessarily web developers) through simple
manipulation of db table fields.
For example to add another field to the
2005 Aug 09
4
Too slow computer?
Hello! I''ve put some questions on this list some weeks
ago and I''ve got good answers. Thank you!
Now I''ve finished my (beautyful) script and I ran it
on my router...
About my script:
It routes packages based on their destination on the
Internet. I have about 1650 preffered destination
networks listed in some file. The script read this
file and marks every package for
2012 Nov 30
3
loop function and integrate?
Hi guys!
I have to compute something and i don't know what i'm doing wrong. my code
is a bit complex, but imagine that is something like this:
a = c(1,2,3,4)
ia = length(a)
x = seq(1,100,length=0.1)
ib = length(x)
int1 = numeric(ib)
b = numeric(ib)
for(j in 1:ia) {
H = function(x) {sin(x + a[j])}
for(i in 1:ib) {
int = integrate(H, lower = 0, upper
2005 May 17
2
ajax insertion sort
Is there support yet for adding something to a list in sorted order?
For example, you have a form to add a new item and you want the new
item to be inserted in the list in the proper order. I''ve noticed
the :position option in the form_remote_tag but it doesn''t seem like
you can use it to keep things in sorted order.
Rod Schmidt
http://rodschmidt.blogspot.com
"Do or
2009 Feb 12
0
[LLVMdev] Eliminate PHI for non-copyable registers
On Feb 11, 2009, at 4:07 AM, Alex wrote:
> In my hardware there are two special registers cannot be copied but
> can only be assigned and referenced (read) in the other instruction.
> They are allocatable also.
>
> br i1 %if_cond, label %then, label %else
> then:
> %x1 = fptosi float %y1 to i32
> br label %endif
> else:
> %x2 = fptosi float %y2 to i32
>
2006 Sep 13
4
Mini_Magick Problem
I can''t for the life of me figure this out. Been banging my head on
this since the weekend, and can''t see what I''m doing wrong.
This code works:
image.resize("640x480")
image.write(path)
I run this and I get the resized file just fine.
This doesnt work at all:
width = 200
height = 100
dimensions = "#{width}x#{height}"
2005 Oct 28
4
find_by_sql column types
Hello--
There must be a better way to do this. I have a class method in my model
that finds averages and does a few calculations using find_by_sql. The
problem I¹m encountering is that all computed columns from MySQL come back
as type string. E.g.,
def self.find_averages(domain_id)
if @@domain_average
return @@domain_average
else
@@domain_average =