lobatt
2009-Sep-09 03:41 UTC
Newbie question: undefined method ''number_with_delimiter''(probably configuration problem)
Hi all: i am using gem to insall rails 2.3.3 and using $rails myapp to generate my application, but strangely i can''t use the number_helper below is my env: export RUBY_HOME=$HOME/ruby export GEM_HOME=$HOME/gems export RUBYLIB=$RUBY_HOME/lib:$RUBY_HOME/lib/ruby:$RUBY_HOME/lib/ site_ruby/1.8 export PATH=$HOME/gems/bin:$HOME/ruby/bin: and: $ locate number_helper.rb /home/lobatt/gems/gems/actionpack-2.3.3/lib/action_view/helpers/ number_helper.rb and i didn''t modify the file under config dir except database.yml. Isn''t actionpack included in rails projects by default? how can i get number_with_delimiter() work? Thanks in advance.
Frederick Cheung
2009-Sep-09 07:36 UTC
Re: Newbie question: undefined method ''number_with_delimiter''(probably configuration problem)
On Sep 9, 4:41 am, lobatt <lob...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all: > i am using gem to insall rails 2.3.3 and using $rails myapp to > generate my application, but strangely i can''t use the number_helper > below is my env:Where are you calling it from ? Fred> export RUBY_HOME=$HOME/ruby > export GEM_HOME=$HOME/gems > export RUBYLIB=$RUBY_HOME/lib:$RUBY_HOME/lib/ruby:$RUBY_HOME/lib/ > site_ruby/1.8 > export PATH=$HOME/gems/bin:$HOME/ruby/bin: > > and: > $ locate number_helper.rb > /home/lobatt/gems/gems/actionpack-2.3.3/lib/action_view/helpers/ > number_helper.rb > > and i didn''t modify the file under config dir except database.yml. > Isn''t actionpack included in rails projects by default? how can i get > number_with_delimiter() work? > > Thanks in advance.
lobatt
2009-Sep-09 07:46 UTC
Re: Newbie question: undefined method ''number_with_delimiter''(probably configuration problem)
Fred: Thanks for your reply, i call it from my controller, like this: class Visitor::UserAgentStatsController < ApplicationController def index VisitorUserAgentStats.find(:all) number_with_delimiter(record.user_agent) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @graph} end end I wonder how can i make number_with_delimtier availabe to my code? while i am using ApplicationController without any require or inlucde directive... On Sep 9, 3:36 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sep 9, 4:41 am, lobatt <lob...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi all: > > i am using gem to insall rails 2.3.3 and using $rails myapp to > > generate my application, but strangely i can''t use the number_helper > > below is my env: > > Where are you calling it from ? > > Fred > > > export RUBY_HOME=$HOME/ruby > > export GEM_HOME=$HOME/gems > > export RUBYLIB=$RUBY_HOME/lib:$RUBY_HOME/lib/ruby:$RUBY_HOME/lib/ > > site_ruby/1.8 > > export PATH=$HOME/gems/bin:$HOME/ruby/bin: > > > and: > > $ locate number_helper.rb > > /home/lobatt/gems/gems/actionpack-2.3.3/lib/action_view/helpers/ > > number_helper.rb > > > and i didn''t modify the file under config dir except database.yml. > > Isn''t actionpack included in rails projects by default? how can i get > > number_with_delimiter() work? > > > Thanks in advance.
lobatt
2009-Sep-09 08:37 UTC
Re: Newbie question: undefined method ''number_with_delimiter''(probably configuration problem)
sorry, the source code should be like this: class Visitor::UserAgentStatsController < ApplicationController def index @graph = Array.new @stats = VisitorUserAgentStats.find(:all) @stats.each do |record| @graph.push(number_with_delimiter(record.user_agent)) end respond_to do |format| format.html # index.html.erb format.xml { render :xml => @graph} end end On Sep 9, 3:46 pm, lobatt <lob...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Fred: > Thanks for your reply, i call it from my controller, like this: > class Visitor::UserAgentStatsController < ApplicationController > def index > VisitorUserAgentStats.find(:all) > number_with_delimiter(record.user_agent) > respond_to do |format| > format.html # index.html.erb > format.xml { render :xml => @graph} > end > end > > I wonder how can i make number_with_delimtier availabe to my code? > while i am using ApplicationController without any require or inlucde > directive... > On Sep 9, 3:36 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > On Sep 9, 4:41 am, lobatt <lob...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi all: > > > i am using gem to insall rails 2.3.3 and using $rails myapp to > > > generate my application, but strangely i can''t use the number_helper > > > below is my env: > > > Where are you calling it from ? > > > Fred > > > > export RUBY_HOME=$HOME/ruby > > > export GEM_HOME=$HOME/gems > > > export RUBYLIB=$RUBY_HOME/lib:$RUBY_HOME/lib/ruby:$RUBY_HOME/lib/ > > > site_ruby/1.8 > > > export PATH=$HOME/gems/bin:$HOME/ruby/bin: > > > > and: > > > $ locate number_helper.rb > > > /home/lobatt/gems/gems/actionpack-2.3.3/lib/action_view/helpers/ > > > number_helper.rb > > > > and i didn''t modify the file under config dir except database.yml. > > > Isn''t actionpack included in rails projects by default? how can i get > > > number_with_delimiter() work? > > > > Thanks in advance.
Frederick Cheung
2009-Sep-09 08:54 UTC
Re: Newbie question: undefined method ''number_with_delimiter''(probably configuration problem)
On Sep 9, 8:46 am, lobatt <lob...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I wonder how can i make number_with_delimtier availabe to my code? > while i am using ApplicationController without any require or inlucde > directive...helpers are available to views only (hence the name view helpers) (at least not unless you start playing some games which you seem to say you don''t want to do see http://snippets.dzone.com/posts/show/1799 for example) Fred> On Sep 9, 3:36 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > On Sep 9, 4:41 am, lobatt <lob...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi all: > > > i am using gem to insall rails 2.3.3 and using $rails myapp to > > > generate my application, but strangely i can''t use the number_helper > > > below is my env: > > > Where are you calling it from ? > > > Fred > > > > export RUBY_HOME=$HOME/ruby > > > export GEM_HOME=$HOME/gems > > > export RUBYLIB=$RUBY_HOME/lib:$RUBY_HOME/lib/ruby:$RUBY_HOME/lib/ > > > site_ruby/1.8 > > > export PATH=$HOME/gems/bin:$HOME/ruby/bin: > > > > and: > > > $ locate number_helper.rb > > > /home/lobatt/gems/gems/actionpack-2.3.3/lib/action_view/helpers/ > > > number_helper.rb > > > > and i didn''t modify the file under config dir except database.yml. > > > Isn''t actionpack included in rails projects by default? how can i get > > > number_with_delimiter() work? > > > > Thanks in advance.
lobatt
2009-Sep-09 10:34 UTC
Re: Newbie question: undefined method ''number_with_delimiter''(probably configuration problem)
Thanks Fred, it is a great help! surely i won''t apply that hack, so i just used str.gsub!(/(\d)(?=(\d\d \d)+(?!\d))/, "\\1,") On Sep 9, 4:54 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sep 9, 8:46 am, lobatt <lob...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I wonder how can i make number_with_delimtier availabe to my code? > > while i am using ApplicationController without any require or inlucde > > directive... > > helpers are available to views only (hence the name view helpers) (at > least not unless you start playing some games which you seem to say > you don''t want to do seehttp://snippets.dzone.com/posts/show/1799for > example) > > Fred > > > On Sep 9, 3:36 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > On Sep 9, 4:41 am, lobatt <lob...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi all: > > > > i am using gem to insall rails 2.3.3 and using $rails myapp to > > > > generate my application, but strangely i can''t use the number_helper > > > > below is my env: > > > > Where are you calling it from ? > > > > Fred > > > > > export RUBY_HOME=$HOME/ruby > > > > export GEM_HOME=$HOME/gems > > > > export RUBYLIB=$RUBY_HOME/lib:$RUBY_HOME/lib/ruby:$RUBY_HOME/lib/ > > > > site_ruby/1.8 > > > > export PATH=$HOME/gems/bin:$HOME/ruby/bin: > > > > > and: > > > > $ locate number_helper.rb > > > > /home/lobatt/gems/gems/actionpack-2.3.3/lib/action_view/helpers/ > > > > number_helper.rb > > > > > and i didn''t modify the file under config dir except database.yml. > > > > Isn''t actionpack included in rails projects by default? how can i get > > > > number_with_delimiter() work? > > > > > Thanks in advance.