search for: to_i

Displaying 20 results from an estimated 407 matches for "to_i".

2008 Jan 11
3
Date range queries return zero results
Hello, I am having trouble getting data ranges to work correctly. I am using the following command to load the db: index << {:title => row[7].to_i, :date => Date.strptime(row[3], ''%Y-%m-%d''), :page_id => row[5].to_i, :page => row[6].to_i, :content_type => row[1].to_i, :article_id => row[4].to_i, :label => row[2],...
2006 Mar 31
10
ruby help / if (cond or cond)
Why this code doesn''t work as expected? It raises exceptions everytime. Tried with || operator, too. validates_each :x, :y do |record, attr| record.errors.add (attr, ''between 1 and 100'') if (attr.to_i>100 or attr.to_i<0) end -- They say money can''t buy happiness? Look at the smile on my face... ear to ear, baby!
2009 Jun 18
3
Date.new.to_time.to_i
What''s going on here!? >> Date.new.to_time.to_i NoMethodError: undefined method `to_i'' for Mon, 01 Jan -4712 00:00:00 -0800:DateTime from (irb):25 >> Date.today.to_time.to_i => 1245308400 >> RUBY_VERSION => "1.8.7" >> Rails.version => "2.1.1" (I''m not sure if this is a rai...
2007 Oct 18
12
first cut at blockless given/when/then
Hi all, I committed a first cut at blockless Givens/Whens/Thens to RSpec''s trunk: cd /path/to/rspec/project svn up cd rspec bin/spec examples/story/calculator.rb Take a look at examples/story/calculator.rb to see what''s going on. Needs docs!!!! Thoughts welcome. I''ve also got a cut at the plain text parser checked in, but it''s not hooked up to anything
2008 Dec 13
2
Need Help in converting php encryption decryption code to ruby on rails
...plain_text +="\0"*(16-(n%16)) end i=0 enc_text=get_rnd_iv(iv_len) enc='''' pass='''' for i in 0..password.size-1 pass +=password[i].to_s(2) end for i in 0..enc_text.size-1 enc +=enc_text[i].to_s(2) end intervalue=(pass.to_i^enc.to_i).to_s iv=password^enc_text.split(0,512) iv=intervalue[0,512] while ( $i < $n ) { $block = substr( $plain_text, $i, 16 ) ^ pack( ''H*'', md5 ( $iv ) ); $enc_text .= $block; $iv = substr( $block . $iv, 0, 512 ) ^ $password;...
2006 Jun 13
17
reconstituting a date
In my view code, I have <%= datetime_select "in_out", "time_in" %> which returns in params :in_out: !map:HashWithIndifferentAccess time_in(1i): "2006" time_in(2i): "6" time_in(3i): "12" time_in(4i): "20" time_in(5i): "24" and I want to save that datetime to a column in the db... if
2006 Oct 17
0
[680] trunk/wxruby2/samples/printing/printing.rb: Cleaned up to use the Ruby naming convention, added #! line, now uses Wx default ID''s in standard menu items.
...(200*actual_scale))/2.0) + pos_y = ((h - (200*actual_scale))/2.0) </ins><span class="cx"> </span><span class="cx"> # Set the scale and origin </span><del>- dc.set_user_scale(actualScale, actualScale) - dc.set_device_origin( posX.to_i, posY.to_i ) </del><ins>+ dc.set_user_scale(actual_scale, actual_scale) + dc.set_device_origin( pos_x.to_i, pos_y.to_i ) </ins><span class="cx"> </span><span class="cx"> Wx::get_app.frame.draw(dc) </span><span class="c...
2006 Mar 22
2
What is wrong in this method??????
Hi, This is my definition of method "add_to_cart" ======================= def add_to_cart count=params[:product][:count] while count.to_i>=0.to_i if params[:product][''dem_quantity''+count.to_s]=="" else @product = Product.find(params[:product][''product_id''+count.to_s]) print @product.name @product.update_attributes(params[:product][''dem_quantity&...
2010 Mar 31
6
any body can help me ?? why is this happen??
Hii All I use ruby 1.8.7 I run irb and type: a = (0.29 * 100).to_i the result is 28 why?????? could u explain to me.. Please???? THank you -- Senior Rails Developer Anton Effendi - Wu You Duan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonra...
2009 Nov 19
12
Templates and loops..
How come this doesnt work? I write this in a normal ruby script it works just fine. <% for cpu in (0..processorcount) %> I want to loop through the number of processor so a specific action can be taken to generate content for a file. I get an error on the master of: bad value for range at /etc/puppet" -Chris -- You received this message because you are subscribed to the Google
2008 May 25
2
storing data from a txt file in ruby?
...e with no problem but im trying to store the list into either a array or hash so i ca say run different methods view, delete ect.. anyhelp would be great this is what i have so far IO.foreach("book_list.txt") do |line| catalog=line.chomp.split(",") products.store(items[0].to_i, [catalog[1],catalog[2].to_i,catalog[3].to_i) end thanks for anyhelp Gabriel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk...
2010 Aug 03
10
Returning last value
...troller of the update action: [code] def update @projeto = Projeto.find(params[:id]) if (@projeto.update_attributes(params[:projeto])) ## Mesmo raciocínio utilizado no create. @permissaoA = Permissao.find(:first, :conditions => ["usuario_id = ?", @projeto.responsavel.to_i]) @permissaoAvancado1 = Permissao.find(:first, :conditions => ["projeto_id = ? and usuario_id = ?", 0, @projeto.responsavel.to_i]) if @permissaoAvancado1.nil? ## Caso tenham excluido os usuários responsáveis, as permissões seriam nulas. Dai ele verifica se vai alterar ou cr...
2006 Jun 28
4
argument out of range...
Hi... I''ve a problem with this : [code] def fir_tahiti @notams=Array.new Notam.find_all_notams().each do |notam| @notams.push(notam) if (to_secs(notam.debut)<Time.now.to_i and to_secs(notam.fin)>Time.now.to_i) end end def to_secs(str = nil) Time.gm(2000+str[0..1].to_i, str[2..3].to_i, str[4..5].to_i, str[6..7].to_i, str[8..9].to_i).to_i if str end [/code] It tells me : "ArgumentError in ListController#fir_tahiti - argument out of range". I alre...
2009 May 28
1
[PATCH server] Change default flexchart view and increase vertical dimension of flexchart area.
...720, - height: 300, + height: 380, wmode: 'transparent', menu: false, - flashvars: { flexchart_data: "<%= url_for :controller =>'/graph', :action => 'flexchart_data' %>/<%= @id %>/memory/<%= Time.now.to_i - 60 * 60 * 24 %>/<%= Time.now.to_i %>/peak" } + flashvars: { flexchart_data: "<%= url_for :controller =>'/graph', :action => 'flexchart_data' %>/<%= @id %>/cpu/<%= Time.now.to_i - 60 * 60 * 24 %>/<%= Time.now.to_i %>/average...
2006 Jul 02
5
Question about setting field values for a belongs_to model
...x] / Rails 1.1.2 Thanks, Stephan ------------------------------------------- Following are 1. mysql table definitions 2. method update in ApplicantController 3. rhtml file, app/views/applicant/edit.rhtml 4. Applicant and Skill models create table if not exists applicants ( id int not null auto_increment, name varchar(20) not null, primary key(id), unique index uniq_index(id) ); create table if not exists skills ( id int not null auto_increment, applicant_id int not null, description varchar(30) not null, primary key(id), unique index uniq_index(id) ); class ApplicantContr...
2006 Nov 04
0
weird problem with content type
...6 the rest of the page that works: http://rdigikam.sitlib.org/tags any idea how I could get rid of this? This is the code of my list.rhtml: <center> <br><br> <% startdate = Time.local(2006,8,1) endate = Time.local(2006,8,31) cal = CalendarGrid.build(Time.local(@passedyear.to_i,@passedmonth.to_i,1)) puts "Content-Type: text/html" %> <% cal.years.each do |y| unless y.year.to_i!=@passedyear.to_i %> <br> <%= link_to(("<"), :year => y.year.to_i-1, :month => @passedmonthparam) %><%= y.year %><%= link_to(("&g...
2006 May 23
2
Ordinalizing a date
I''m trying to use the ordinalize() method to ordinalize a day. Here''s how far I''ve gotten: @reportday = Time.now.at_beginning_of_week.strftime("%d").to_i @ordinalized_reportday = "#{@reportday}".ordinalize I was thinking it wasn''t working because the date is being returned as a string, however I added the .to_i and still it returns an error. The error I''m getting is: undefined method `ordinalize'' for "22...
2006 Mar 17
1
How to update values in database in this form?
...duct.quantity%> </td> <td> <%=text_field("product", "dem_quantity"+i.to_s, "size" => 20)%> </td> </tr> <% i=i+1 %> <% end%> <tr> <%=hidden_field ''product'',''count'', :value=>i.to_i-1%></td> <td colspan=4 align="center"> <%= submit_tag("Add to Cart") %> </td> </tr> </table> <%= end_form_tag %> ================================== ======products_controller.rb======= def add_to_cart count=params[:product][:coun...
2005 Sep 23
6
problem with acts_as_tree
...nder MacOS Tiger. I was trying to use acts_as_tree as described in the rails book. So I have something like: class Category < ActiveRecord::Base acts_as_tree :order => "title" end create table categories ( id int not null auto_increment, title varchar(100) not null, parent_id int, constraint fk_category foreign key (parent_id) references categories(id), primary key (id) ); When I try to use category.children I get an invalid member error. When I changed this t...
2006 May 11
9
Undoing a SHA1
Hello for my password recovery system I want to recover the users password and send it to them. In the DB its saved via SHA1 (login generator) -- Posted via http://www.ruby-forum.com/.