search for: number_with_precision

Displaying 17 results from an estimated 17 matches for "number_with_precision".

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/.
2006 Mar 02
0
syntax for number_with_precision
I normally use number_with_precision in my views and I''ve never had a problem. Now however, I need to use it in my controller because my Ajax method is calling the controller and the controller will return values to it which will be displayed in the span of my html document. In short, what am I doing wrong in the stateme...
2006 Feb 21
4
displaying double digits
Hi, I have a question about displaying digits in Rails. whenever I print the price of an item, if the last digit is a zero or double zeros then it doesn''t display properly. How do I display a number so that it looks like currency? thank you! -- Posted via http://www.ruby-forum.com/.
2008 Jul 01
2
rateable plugin problem
...at http://www.naffis.com/blog/articles/2006/08/31/rails-ajax-star-rating-system but there seem to be some problem. I am getting the following error You have a nil object when you didn''t expect it! The error occured while evaluating nil.rating Extracted source (around line #1): 1: <%= number_with_precision(picture.rating, 1) %>/5 Stars<br> 2: <ul class=''star-rating''> 3: <li class=''current-rating'' style=''width:<%= (picture.rating * 30).to_i -%>px;''> 4: Currently <%= number_with_precision(picture.rating, 1...
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?
2006 Feb 24
2
Formatting values of numbers using text_field
Anyone have a quick solution on how to format a number in a text_field tag? <% text_field "price", "amount" %> returns 100.0 and it would be nice if it showed 100.00 Of course, number_with_precision works nicely, but how do you make that work with text_field? I thought maybe overriding the getter in the model. However, this means I would have to bring the helper code into the model which I''m not sure I like. Brian Hogan Web Development Learning & Technology Services Schofield...
2007 Dec 06
3
number_to_currency
...rator, delimiter = options.delete("precision") { 2 }, options.delete("unit") { "£" }, options.delete("separator") { "." }, options.delete("delimiter") { "," } separator = "" unless precision > 0 begin parts = number_with_precision(number, precision).split(''.'') unit + number_with_delimiter(parts[0], delimiter) + separator + parts[1].to_s rescue number end end it definately should work, but why doesnt the £ sign come as a question mark I have also tryed: def number_to_currency_gbp (n...
2008 Dec 06
0
Problem in number_helper.rb ?
...I noticed that the number_to_currency helper didn''t work anymore (it just returned the numeric value, without any currency). I tracked down the error and saw that editing line 89 ( number_to_currency method) as follows solved the problem : Old piece of code : begin format.gsub(/%n/, number_with_precision(number, :precision => precision, :delimiter => delimiter, :separator => separator) ).gsub(/%u/, unit) rescue number end New one : begin format.gsub(/%n/, number_with_precision(number, :precision => precision, :delimiter => delimiter,...
2006 Sep 23
8
acts_as_rateable plugin help!
...ections located at http://www.naffis.com/blog/articles/2006/08/31/rails-ajax-star-rating-system but i fail at working it. i am getting this error You have a nil object when you didn''t expect it! The error occured while evaluating nil.rating Extracted source (around line #1): 1: <%= number_with_precision(asset.rating, 1) %>/5 Stars<br> 2: <ul class=''star-rating''> 3: <li class=''current-rating'' style=''width:<%= (asset.rating * 30).to_i -%>px;''> 4: Currently <%= number_with_precision(asset.rating, 1) %&g...
2007 Jun 04
1
acts_as_rateable in Beast
...d Is there a way to dynamically update (ajax) the rating in my view without having to refresh the page? I''ve tried link_to_remote and am loading javascript files but it does not seem to be working, my partial looks like this: <div id="<%= asset.id %>"> <%= number_with_precision(asset.rating, 1) %> (<%= asset.ratings.size %> votes) | <%= link_to_remote("voteup", {:url => { :controller => "posts", :action => "voteup", :id => asset.id, :rating => 1, :rateable_type =...
2006 Feb 28
4
number_to_currency UK pounds
I work in the UK and therefore most of my currency figures will be in UK pounds. I realise that to format a number to a currency format I can use: number_to_currency(amt, :unit => "?") but it would be more convenient to set ? as the default currency symbol. What is the best way to do that? Should I edit line 39 of this file:
2006 Mar 01
3
Form helpers and overloaded methods - help!
...of looking at the database / attributes collection. Let''s say I have a column called ''price'' in my database table "books" Let''s say I want price to always come back as a special format when I query my model.... So in my model, I do def price number_with_precision(self.attributes[:price]) end In a view, @book.price comes back formatted correctly as expected. However, <%=text_field "book", "price" %> bypasses my method and gets the unformatted price. It just doesn''t seem consistent. I''m currenly playing arou...
2006 Jan 17
9
Formatting a float with a set number of decimals
Another newbie question: How do i convert a float to a string, rounded to a certain number of decimals? Thanks -- Posted via http://www.ruby-forum.com/.
2006 Jul 21
3
adding numbers
hi! how can i add all the values from one tables field? i mean, i have a table with the entries of a booking (amount), and at the end, i want to have the total. i tried with different loops making a method in the model, but nothing. im doing something wrong, but i dont know what. please could somebody help me? ty!! -- Posted via http://www.ruby-forum.com/.
2009 May 01
0
Graticule / acts_as_geocodable error?
...39;) The only mention of ''precision'' is in my schema: t.decimal "latitude", :precision => 15, :scale => 12 t.decimal "longitude", :precision => 15, :scale => 12 and when I render the distance coming back: Distance: <b><%= number_with_precision listing.distance, :precision => 1 %> miles away</b> I can''t figure out what "attribute" it''s talking about. Thanks for the help.
2010 Apr 26
0
add a new format to locales
...ns[:unit] || defaults[:unit] separator = options[:separator] || defaults[:separator] delimiter = options[:delimiter] || defaults[:delimiter] format = options[:format] || defaults[:format] separator = '''' if precision == 0 begin format.gsub(/%n/, number_with_precision(number, :precision => precision, :delimiter => delimiter, :separator => separator) ).gsub(/%u/, unit) rescue number end end do you have any idea how can i solve that? thanks best regards matthias -- You received this message because you are su...
2006 Aug 04
0
How do you use form helpers in your controllers or classes?
I need to use the number_with_precision Form helper in my controllers and classes. How do i do this? Thanks in advance Chris -- Posted via http://www.ruby-forum.com/.