I would like to do a cron job every 10 minutes, but my system only does 1 hour. So I'm looking for a method to do this. I've seen Timer and sleep but I'm not sure how to do this or even better yet a resource for achieving this.
...
This isn't webservices. I want to pass a url to a controller and then have it fetch the html from that page. Then store the information in a db.
What do you think? How can I accomplish this?
...
Hi
I know these are the basics of rails but i still don't know the full difference between = sign and => and the difference between @some_variable, @@some_variable and :some_variable in rails.
Thanks.
...
Hi to all, i have:
ruby1.9.1-full
rubygems1.9.1
installed, these are the only versions i have installed.
I am not able to require any gems with the following syntax:
require 'rubygems'
require 'gem_name'
I get this error:
LoadError: no such file to load -- active_record
from (irb):2:in `require'
from (irb):2
from /usr/bin/irb:1...
I have an array of elements. If I do a arr.max I will get the maximum value. But I would like to get the index of the array. How to find it in Ruby
For example
a = [3,6,774,24,56,2,64,56,34]
=> [3, 6, 774, 24, 56, 2, 64, 56, 34]
>> a.max
a.max
=> 774
I need to know the index of that 774 which is 2. Is this possible at all??
...
I'm helpless on regular expressions so please help me on this problem.
Basically I am downloading web pages and rss feeds and want to strip everything except plain words. No periods, commas, if, ands, and buts. Literally I have a list of the most common words used in English and I also want to strip those too but I think I know how to d...
I have a standard Rails application.
When a Tip is created, I would like to create a Message for each User who is interested in that Tip.
This sounds simple right? It should be...
So, we start with a Tip Observer:
class TipObserver < ActiveRecord::Observer
def after_save(tip)
# after the tip is saved, we'll create some messages...
Official Rails site states it supports 1.8.x versions, but did anyone try to run Rails 2.3.8 on ruby 1.9.2?
...
This works just fine in my dev environment (I am rewriting a css file):
File.open(RAILS_ROOT + '\public\stylesheets\colors.css', 'w') do |w|
w.puts 'some_text'
end
But when I run it in my prod environment (on Dreamhost) nothing happens - the file is not modified - nothing.
What I need to be able to do is to overwrite an exist...
I have an array like this:
[234, 235 , 343, 445]
I want to convert it to look like this
[[234],[235],[343],[445]]
Is there core library function in ruby 1.9.2 could help me to do this fast? and if not is there a fast way?
I did a small tests
def test1
array = []
10000000.times do
array << rand(1000000)
end
ti...
Hi,
I have a Tag object (id, name) and a Tagging object (id, tag_id, type). I want to find all the tags that have a name like "kevin" and for which I can find a foreign Tagging object with type set to "people" (type can be set to people or some other tagging stuff).
I tried with a complex SQL request in a Rails Tag.find method but didn...
Hi everyone, I am stuck in an (apparently) simple problem.
In my event_controller I have the i_like_it action:
def i_like_it
@event = Event.find(params[:id])
... # logic
respond_to do |format|
format.js
end
end
In my case "i_like_it" is called with :method => PUT (it is an Ajax
call, "i_like_it.js.erb" will...
if not whats the maximum while still remaining efficient?
im creating 14 threads, each of which opens a list of URLs(about 500) creates a new thread for each one, which then downloads it, and adds it to a MySQL db. The MySQL pool size is set to 50.
This is a rake task in RoR
Would this work better using Kernal#fork or some other met...
I haven't been able to find a very good way of getting 10 random records out of a sqlite database. Seen a few examples that work with mysql, but they don't seem to work well with sqlite even though I am trying to us Random() instead of rand().
I have tried to get random numbers and then get the records by id, but for some reason I am ge...
So I was doing a refresher on Ruby and I saw this guy's blog about creating class-level instance variable in Ruby. I am still trying to understand what the code actually does here. His blog can be found here
http://railstips.org/blog/archives/2006/11/18/class-and-instance-variables-in-ruby/
and I have created a simple code based on his...
I am currently writing a quick script in Ruby that goes through all the contents of two folders, and returns a list of all the files that are not in either of the two folders.
Currently what I am doing is storing the paths of all the files of each directory in an array:
Find.find(dir1) do |path|
if File.file?(path)
directory1_file...
In Java if I want a simple data structure I would simply declare it in a class something like this
class MySimpleStructure{
int data1;
int data2;
MyOtherDataStructure m1;
}
Then I would later use it in my program,
MySimpleStructure s1 = new MySimpleStructure();
s1.data1 = 19;
s1.m1 = new MyOtherDataStructure();
How to do a...
Using Watir, how can I return the text of the currently selected item in a drop down list? It appears that getSelectedItems is deprecated.
...
Hi there
I'm trying to run a query where I want to ignore records with a certain email address...
@foo = Bar.all(:email => 'xxx') <--- Except I want to negate where this email address exists.
Please let me know how I can do it.
Thanks!
...
I have an XML file (actually a Visual C# project file) that I want to manipulate using a Ruby script. I want to read the XML into memory, do some work on them that includes changing some attributes and some text (fixing up some path references), and then write the XML file back out. This isn't so hard.
The hard part is, I want the file ...