search for: numberhelper

Displaying 20 results from an estimated 22 matches for "numberhelper".

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 Woops! Lets try to be more explic...
2006 Jul 14
0
NumberHelper.number_to_human_size
I doubt this is the correct place to post this but I was unable to post to rails-core so I am posting here. Please let me know if there is a better place to send this. NumberHelper.number_to_human_size returns ''KB'' as the abbreviation for kilobyte. According to the SI standards kilobyte should be abbreviated ''kB''. I know this a v ery minor issue but my boss is concerned enough about it that I have to write a new human_size helper... Tha...
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?
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: <% phone_number = number_to_phone(@phone_number.phone_numb...
2006 Jul 09
2
float to percentages
Hi, good day to us all, i was wondering if there was some kind of method for floats to change them into percentages...i looked up some functions in ruby-doc, but didn''t find anything suitable. is there such a thing? thanks, harp -- Posted via http://www.ruby-forum.com/.
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
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
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
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 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/.
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
2011 Oct 26
3
Overriding number_to_human (Rails 3.0.5)
...#39;'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: lib/number_helper_overrides and put the override code in there: module ActionView module Helpers module NumberHelper def number_to_human(number, options = {}) #the code in here bla bla end end end end then in environment.rb I put: require "number_helper_overrides" Is this the proper way to override in rails 3? If so, then should I really need to put the "require"...
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 Jan 24
7
formatting numbers with commas
I needed to format numbers with commas to make it more human readable. Here''s how I did it. def commify(number) c = { :value => "", :length => 0 } r = number.to_s.reverse.split("").inject(c) do |t, e| iv, il = t[:value], t[:length] iv += '','' if il % 3 == 0 && il != 0 { :value => iv + e, :length =>
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
2006 Jan 06
3
Where to place a global function
Hi all, I have a little function called format_price(price) that simply formats the argument as a dollar sign, dollar amount, dot and penny amount. Then, in a .rhtml file, I could do this: <%= format_price(item.unit_price * item.quantity) %> But where do I put the format_price() function definition? The app couldn''t find it in app/controllers/application.rb. Where do I put it
2006 Oct 08
3
Call an helper method from a controller
Hello, this have been debated few times in the forum but I didn''t found a satisfying solution : my problem is very simple, I have few methods dealing with cookies that are intended to be used in controllers and views. Let say I have the read_cookie() method. Because it deals with the response object putting this method in the /lib directory doesn''t fit nicely because I