similar to: Call an helper method from a controller

Displaying 20 results from an estimated 2000 matches similar to: "Call an helper method from a controller"

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 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
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 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
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 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 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 Mar 03
1
number_to_currency() helper == non DRY == could be improved
Hi all, Apologies in advance if I got this one wrong, I''m still just a newbie ;-) Going through the Apple ADC RoR tutorial it suddenly occurred to me that the ''number_to_currency()'' helper method was not DRY streamlined. Scenario:: The "number_to_currency()" methods options hash works great when I need to dynamically display different currencies when I
2008 Feb 05
5
how can my model reference a helper?
I know, I know, they''re not allowed to. But here''s my problem. I''ve got a really simple model with two fields, name and price, which I want to show in a form select drop-down. "collection_select" takes a ''text_method'' parameter, which is the method in the model that gets its value placed in the <option> tag. Because I want to show both
2006 Aug 18
4
HELP!!!! - number_to_currency in model?
Hi, I''m trying to use number_to_currency in one of my models, but i''m getting the following error: undefined method `number_to_currency'' for #<Product:0x396d680> Obviously, my Product model can''t access number_to_currency -- is there something I need to do to make it available? Thanks so much for your assistance. -- Posted via
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:
2007 Dec 06
3
number_to_currency
I am using the number to currency function because i live in the uk and the company want me to only show values of the pound of course.I have created all my application using ruby script/generate scaffold_resource.... I have come across with a problem... this code is in my applcation: def number_to_currency(number, options = {}) options = options.stringify_keys precision, unit, separator,
2009 Mar 04
10
total per user
so I am trying to sum month over month the amount that a user has posted. So for example: User 1: Jan $3000 Feb $4000 March $1500, etc. I can get this to work if I sum totals (aggregate of all users) but just not by user. Here is my code in the controller: def index @users = User.find :all, :order => ''name ASC'' @deal_groups = Deal.find(:all).group_by {|t|
2010 Oct 16
3
Doubt with symbols in Rails
I was trying to write a wrapper for number_to_currency to return currency in pounds. I used a helper class to do this. def number_to_pounds(amt) number_to_currency(amt, :unit => "£") end This works fine, but I am trying to understand why I can''t use a symbol to pass the values. I thought symbols were like pointers. (you now know I am a newbie). def
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/.
2006 Jan 06
2
How do I reference eagerly loaded Models in the View?
[I hope the repost isnt'' "minded". Following the advice of another thread I''ve changed the subject to a question. If I haven''t included important info, please ask. My database is being unduly killed. Jodi] Cheers on-the-Rails-ers, Before I start, I''ve read the ActiveRecord docs on eager loading, but for the life of me, I can''t seem to get
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 23
3
Decimal comma instead of decimal point (i18n issue)
Hello, What is the easiest way which enables usage of decimal comma "," instead of decimal point (".") . I would like to force all RoR views to display float numbers with comma instead of decimal point and also to allow insertion of float numbers with comma in forms. Thanks in advance, Karel -- Posted via http://www.ruby-forum.com/.