Hello,
I want to run two rails websites (homepage and app) on the same database. However, migrations dont work because both websites try to use schema_migrations table at the same time.
Is it possible to override default schema_migrations table name? Any other ideas how to solve this problem?
...
I am using Sphinx with the Thinking Sphinx plugin. I have indexed a model called Venue with the following code (and the rake thinking_sphinx:index command)
define_index do
indexes :name
indexes city
indexes zip
end
I obtain the results in my controller with this code:
@venues = Venue.search params[:search]
and I render...
What is active_record doing to the signal processes under windows (I don't see this with the same versions on the mac) that causes it to behave so strangely? For instance:
require 'rubygems'
trap("INT"){puts "interrupted"}
puts __LINE__
sleep 5
require 'active_record'
trap("INT"){puts "interrupted again"}
puts __LINE__
sleep 5
When I...
In my Rails application I have a User model (more or less built by RESTful Authentication), and several other models belonging to the user.
So let's say, for example:
user has_many :posts
post belongs_to :user
Anywhere in the users resource I can access the user variables as I would expect.
@user.name, @user.email, @user.login, etc. a...
I have been looking for an elegant and efficient way to chunk a string into substrings of a given length in Ruby.
So far, the best I could come up with is this:
def chunk(string, size)
(0..(string.length-1)/size).map{|i|string[i*size,size]}
end
>> chunk("abcdef",3)
=> ["abc", "def"]
>> chunk("abcde",3)
=> ["abc", "de"]
>> chunk("abc...
I need to read the last 25 lines from a file (for displaying the most recent log entries). Is there anyway in Ruby to start at the end of a file and read it backwards?
...
One problem encountered with mutation testing is that it's slow, because by default you do a full test run (either a test file, or a suite of test files) for each mutation generated.
One way to make mutation testing faster would be to stop the test run for a given mutant once a single failure has been encountered (but only during mutati...
I am trying following code to determine video resolution by running ffmpeg utility as subprocess and gain its output and parse it:
IO.popen 'ffmpeg -i ' + path_to_file do |ffmpegIO|
# my parse goes here
end
...but ffmpeg output is still connected to stdout and ffmepgIO.readlines is empty. Are there some special treatment needed fo...
There seems to be an odd discrepancy between the messages contained in Ruby Exceptions raised directly and raised from within evals. For instance, the following code:
def foo
raise "Help!"
end
puts "\nRescue foo"
begin
foo
rescue RuntimeError => e
puts e.message
end
puts "\nRescue eval 'foo'"
begin
eval "foo"
rescue RuntimeError =...
If I have d = DateTime.now, how do I convert 'd' into UTC (with the appropriate date)?
...
This is 2009, back in 2001 or so, there used to be no good bindings for sound playback in ruby.
Has there been a change? I am looking for something to control playback of either raw sound or mp3, ogg and flac. My Googling has turned up dry.
Edit: Linux, OSX and if possible Windows.
...
I have 2 apps
1 Ruby (not written by me. I understand nothing of Ruby) and the other ASP.Net
The Ruby app determines the users's IP address (I'm told "using first IP found in "HTTP_X_FORWARDED" )and passes a hashed version of it to the ASP.Net app.
The ASP.Net app then determines the Client's IP address again (using Request.UserHostA...
Hi All,
I have a ruby hash that looks like this
{ "stuff_attributes" => {
"1" => {"foo" => "bar", "baz" => "quux"},
"2" => {"foo" => "bar", "baz" => "quux"}
}
}
and I want to turn it into a hash that looks like this
{ "stuff_attributes" => [
{ "foo" => "bar", "baz" => "quux"},
{ "foo" => "bar", "baz" => "quux"...
Something like
Rails.cache.delete('site_search_form')
doesn't seem to work. Is this possible? Thanks.
...
We have the following situation:
We invoke a url which runs an action in a controller. The action is fairly long running - it builds a big string of XML, generates a PDF and is supposed to redirect when done.
After 60 seconds or so, the browswer gets a 200, but with content type of "application/x-unknown-content-type" no body and no Re...
I frequently must correct the following rails code:
assert_equal value, expected
The two arguments to assert_equal are out of order, and should read:
assert_equal expected, value
In vim, what is the most efficient way of going from the first line to the second?
...
I am trying to read in from a few files using something like this
IO.foreach("TeamFields.txt") { |line| fieldNames.push(line.chomp) }
It works fine when running the from the command line, but when I package to an .exe with shoes and run it can't find the file. Is there a way to specify a path relative the the .exe or do I have to prov...
I think my question is best described as an example. Let's say I have a simple model called "Thing" and it has a few attributes that are simple data types. Something like...
Thing
- foo:string
- goo:string
- bar:int
That isn't hard. The db table will contain three columns with those three attributes and I can access them w...
I'm trying to create unique anchors for every comment on my blog so a person can take the url of an anchor and paste it in their browser, which will automatically load the page and scroll down to the point in the page where their comment starts.
Perhaps I'm going about this the wrong way but I've tried this which was to no avail.
Comm...
A couple of months ago I read a blog post about a ruby gem that could determine the programming language by reading the code itself. For the life of me I can't recall the blog or the name of the gem. And googling for "ruby programming language guess" and variations thereof aren't helping.
Anyone happen to know the name of the gem in q...