Displaying 20 results from an estimated 8000 matches similar to: "float to percentages"
2009 Jul 24
7
number_to_currency not working since 2.1.1
Back in 2.1.1 everything was sweet:
Loading development environment (Rails 2.3.3)
>> include ActionView::Helpers::NumberHelper
=> Object
>> number_to_currency(12.3)
>> "$12.30"
Then I upgraded to 2.3.2 and:
Loading development environment (Rails 2.3.3)
>> include ActionView::Helpers::NumberHelper
=> Object
>> number_to_currency(12.3)
>> 12.3
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 May 29
2
Convert bytes to kb or mb in words
Using File.size(myfile) I can get the size of the uploaded file in _bytes_.
Does anybody know of a function to convert bytes into a more human readable
format?
If I had a wish list for a "file_size_in_words()" function, it would do
this:
10752 bytes becomes "10.5 Kilobytes".
2213814 bytes becomes "2.1 Megabytes".
238 bytes becomes "Less Than 1 Kilobyte".
2006 Feb 23
6
irb with rails
I was trying to access rails functions (number_with_precision) from an
irb session.
It can''t find the method. How do I load the libraries ?
TIA
LS
--
Posted via http://www.ruby-forum.com/.
2009 Aug 03
5
Decimal datatype and trailing zeros
Hello
I''ve encountered a little problem with zeros using the decimal data
type
Specifying a scale of 3 and inserting a number with 3 zeros after the
point (for example 12345.000) it gets correctly stored in the
database, but rails insists to show me the number only with the first
zero after the point (12345.0)
There is a way to tell rails to not truncate at the first zero?
2009 Sep 24
2
Calling ActionView from uninheriting class
Hi Gurus, I have a class, specified in models cart.rb, which doesn''t
inherit from anything--it''s just a container
class Cart
...
I just discovered I can''t call number_to_currency in that class. Any
idea how to "include" it in my code? I tried
ActionView.number_to_currency without luck. I could kill a few lines
of non-DRY regexp code in cart.rb if I could
2006 Apr 08
2
Cannot use view helpers in RJS helpers
Any ideas why I would get an error in a RJS helper on view helpers
such as number_to_currency.
Example:
# my_template.rjs
page.help_me
# my_helper for my_controller
def help_me
number_to_currency(10)
end
I have also tired page.number_to_currency but that doesn''t work either.
Cheers,
Nicholas
2006 Aug 14
2
ActionPack: number_to_phone error
Question about the number_to_phone function as provided by rails in actionpack:
http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html
If I do this in my controller:
num = number_to_phone(params[:phone_number])
I get this error:
undefined method `number_to_phone'' for #<TicketsController:0xb7a2bfcc>
Whereas if I do this in my view:
<%
2006 Apr 05
1
number_to_currency inside model
I was wondering if this is possible.
I have a model (Item) that contains products. These products have prices
that I''d like to format using number_to_currency. Rather than doing this
several times inside the view, I thought it might be nice to do it once
inside the model.
The item table has an field called regular_price which holds a currency
amount. I would like to do something
2007 May 12
4
Multiply and format with thousands separator
I have just started with Ruby and Rails and am still greatly confuse,
finding the usual tutorials not much help.
What I want to do is take two numbers from my database, multiply them
together and display them in a list with a comma for the thousands
separator. This would be very easy to do in a spreadsheet, so I assumed
it would be easy to do in Ruby on Rails but I can''t work out how.
I
2006 May 21
6
Is there a way to call helper methods in a controller?
Hi,
Is there a way to call helper methods in a controller?
I want to do something like this in my controller
Class MyController < Action....
def my_method
string = link_to "some_url", :controller => "home", :action => "command"
end
end
link_to is an ActionView helper method and it seems that I couldn''t access
the method in the controller
2006 Aug 09
7
changing find method
Hi,
i was wondering if there was a nice clean way(after all, it is ruby) to
change the find method of a certain model/class (Page) so that if i
wanted to use a find method on a @page instance it would return only
specific rows from the table(if the page.published == true/false:
the pages table looked like
SQL:
...
id int not null auto_increment,
published tinyint(1) not null,
something
2013 Feb 27
4
My SCSS compiled CSS lacks "/assets" in the generated urls
Running "rake assets:clobber assets:precompile" will generate files like
"application-xxx.css" with incorrect urls after upgrading to Rails 4.
For example url(/fields/xxx.png) when it should be
url(/assets/fields/xxx.png). For some unknown reason it worked once in
development mode, but after running rake assets:clobber I can''t get it
to work again...
Any ideas
2006 Jul 11
1
smpt server
Hi,
i am now in the process of building a newsletter system which will send
out emails to users that have enlisted to a certain group;
everything''s going fine, and i an towards the end of this project...now
the real part of the story kicks in, where i need to check to see if the
thing is working or not. i have been looking over the development.log
file, and i see that the emails
2006 Jul 13
2
mail sending
Hi,
i was hoping someone could reference me to some good documentation on
emails in ruby and emails in general. i am in the end-process of
building an app with a newsletter application in it, and was hoping to
get some references on good places to start off with - - not just in
rails/actionmailer, but email/smtp/sendmail/whatever/protocols when to
use what, what''s best to use when,
2006 Mar 17
2
How to let the layout be more OO?
I am confused about the @content_for_layout.''cause it will display all
the views in the layout.Do I have any methods to let the layout be more
OO? I mean that for example,the app currently have more than one views
to be displayed,but only some of them to be displayed at the same time
at different <div></div> units. I hope there exists a kind of way that:
<%= if
2011 Oct 26
3
Overriding number_to_human (Rails 3.0.5)
I encountered a problem today, in that the number_to_human helper has a
defect where it spits out an error when passed any number bigger than 0 and
less than 1.
eg number_to_human(0.2) gives "nil can''t be coerced into fixnum"
So, I found this patch:
https://github.com/rails/rails/commit/7c8a5f5759a0c63945d133280fb78deaa86b65b9
Now to apply it, I had to create a file:
2006 Jan 27
3
Formatting Data in rhtml
Is there a simple way to format your data in the .rhtml file?
I come from a PHP/Smarty background, and in the templates, I''ve used
what is called "modifiers" to format data.
{$price|currency_format} # displays in currency format
{$description|truncate:"100"} # Truncates the description after 100
characters
It seems like the template (rhtml) would be the ideal
2006 Jun 08
1
formatting amount
Hi,
What is the best way to format amount in RoR?
e.g $12000.937 => $12,000.94
Thanks,
Hari
--
Posted via http://www.ruby-forum.com/.
2005 Jul 24
1
international version for number_to_currency ?
bryce benton wrote:
> number_to_currency(1234567890.506) => $1,234,567,890.51
BTW agile book does mention this ..
will this number_to_currency(x) be internationalized ? or i can set it
to Indonesian for example (or to any other languages rather than just
English) ?
--
Salam hangat,
<%= Arie %> | http://blog.riyari.com | Y!: riyari3
email: ariekusumaatmaja_at_riyari_dot_com