Displaying 20 results from an estimated 46 matches for "number_to_curr".
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...
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 call
"number_to_currency()", as long a I have an idea of what the currency
should b...
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 like what''s below, but I get the
following error message:...
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 explicit
>> number_to_currency(12.3,...
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 |...
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:
C:\ruby\lib\ruby\gems\1.8\gems\actionpack-1.11.2\lib\action_view\helpers\number_helper.rb
so that options.delete(&qu...
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
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, delimiter = options.delete("precision") {
2
}, options.delete("unit") { "£" }, options.delete("separator") { "." },
options.delete("delimiter") { &q...
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 just use
number_to_currency.
Many TIA,
Craig
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
no...
2009 Mar 04
10
total per user
...for user in @users %>
<ul id="monthly-revs">
<strong><li><%=h Time.now.year %></li></strong>
<% user.deal_groups.keys.sort.each do |month| %>
<li><%=h month.strftime(''%B'') %></li>
<li><%=h number_to_currency(user.deal_groups[month].collect
(&:rev).sum, :precision => 0) %></li>
<% end %>
</ul>
<% end %>
Ultimately, I want to make this a partial but for now am getting the
following error
NoMethodError in Users#index
Showing app/views/users/index.html.erb where l...
2006 Jan 06
2
How do I reference eagerly loaded Models in the View?
...g - see "pst" below)
And in the view, I reference as such:
@work_order_items.each {|item| @work_order_items_table.data <<
Hash["Part #", item.ProductsAndServices.part_number,"Description",
item.description, "Quantity",item.quantity, "Price",
number_to_currency(item.price), "Extended",
number_to_currency(item.sub_total)]}
The above generates @work_order_items.count queries to the
ProductsAndServices table. Why is that? Do I reference the eagerly
loaded data incorrectly?
With the same symptom, further down in the same view I make a call to...
2008 Feb 05
5
how can my model reference a helper?
...p-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 name and price, I had to add an extra method
in my model-
def description
"#{name} - #{number_to_currency(price)}"
end
But this fails, because now I''m trying to reference number_to_currency
(a helper method) from my model. How can I get around this?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you...
2009 Apr 10
0
MySql Memory Error
...r => ''accounts.name'')
end
index.html.erb
<% @page_title = ''Subscriptions'' %>
<% if @stats %>
<h1>Revenue Summary</h1>
<table id="stats">
<tr>
<th>Last Month</th>
<td><%= number_to_currency(@stats[:last_month]) %></td>
</tr>
<tr>
<th>Last 30 Days</th>
<td><%= number_to_currency(@stats[:last_30]) %></td>
</tr>
<tr>
<th>This Month</th>
<td><%= number_to_currenc...
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/.
2008 Apr 24
7
Please help. The error occurred while evaluating nil.name
...blic.gmane.org %>
<table class="products" id="table1" cellspacing="2" cellpadding="3"
border="3">
<tr>
<td>
<table width="25%">
<tr>
<tr>
<td><%= @results[1].name%> | <%=
number_to_currency(@results[1].price)%></td>
</tr>
<tr>
<td><%= link_to image_tag(@results[1].image_url, :size =>
''100x100'', :border => "0")%></td>
</tr>
<tr>
<td><%= h(truncate(@results[1].descr...
2006 Mar 12
1
alias_method interferes ApplicationHelper
Hello,
I''m using Ruby 1.8.4 (darwinport), rails-1.0.0 (gem) , Powerbook / Mac
OS X 10.4.5 , Webrick.
How come Rails always raises NoMethodError for my helper (must_fill and
rp or number_to_currency_rp) in application_helper.rb ?
I doubt that alias_method is the culprit, but if i give #
comment then there will be no errors at all ... :/
what am i doing wrong? is it a bug or stupid me? Thx
------------------
This is my helper:
------------------
module ApplicationHelper
alias_method :rp...
2008 Aug 25
2
maths not working (can't get this)
...e
} ) %><br>
<%= submit_tag "Proceed to quotation" %>
<% end %>
------------
OUTPUT PAGE
<hr>
<h1><%= @course.name %></h1>
<hr>
<br>
<%= @time.to_formatted_s(:long_ordinal) %><br>
<br>
Price per week: <%= number_to_currency(@course.price_per_week, :unit =>
"£", :separator => ".", :delimiter => ",") %><br>
Duration: <%= @course.duration_in_weeks %> weeks<br>
Registration Fee: <%= number_to_currency(@course.registration_fee, :unit
=> "&...
2006 Mar 10
5
PDF::Writer Simpletable Iteration
Hello All:
I have been working with <a
href="http://ruby-pdf.rubyforge.org/pdf-writer/index.html">Austin
Ziegler''s PDF::Writer</a> as a means to produce PDF documents from my
Rails app. I am stumped on how to iterate through a collection of items
and output them in a table format. The way I have tried it so far only
returns the last item in the collection -
2007 Nov 27
3
Disappearing decimals... please help!
...le numbers. Rails seems
to completely ignore my decimal input. So as a consequence, 10.41
becomes 10.00, always.
Here''s some worthwhile stuff:
within my 004_create_products.rb file:
:price, :decimal, :percision => 2, :default => 0
And calling the product price in a view:
<%= number_to_currency(product.price, {:precision => 2}) %>
That''s all I can really think of that could be of help. Is this all in
my head, or am I retarded and missing something?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this messag...