I'm returning a complex result of indeterminate size that I will need to handle again and again, so I'm wondering what is a good way to package it?
something like this
loop>>>
@results = { external_id => { :name => name, :type => type } }
or
@results = [ { :external_id => external_id, :name => name, :type => type } ]
or?
end>>>...
Are Rails controllers multithreaded?
If so, can I protect a certain piece of code (which fires only once every ten minutes) from being run from multiple threads by simply doing
require 'thread'
Thread.exclusive do
# stuff here
end
on do I need to somehow synchronize on a monitor?
...
Suppose I have strings like the following :
OneTwo
ThreeFour
AnotherString
DVDPlayer
CDPlayer
I know how to tokenize the camel-case ones, except the "DVDPlayer" and "CDPlayer". I know I could tokenize them manually, but maybe you can show me a regex that can handle all the cases?
EDIT:
the expected tokens are :
OneTwo -> One Two
......
It's hard to search this in google because it consists of symbol? What does ||= stand for? And how does it work?
Thanks.
...
I'm having my first go at using Google charts using a Ruby wrapper called gchartrb. My first attempt was to draw a bar chart, which works fairly well, except that the largest value (Trend 2 - 800) hits the top of the y axis. I'm guessing this is a Google Charts issue, but I was wondering if there was a way around this problem so all va...
Hi,
i've added code
config.gem "authlogic-oauth", :lib => "authlogic_oauth"
to the environment.rb file in my app and got error
undefined method 'add_acts_as_authentic_module' for ActiveRecord::Base::Class
is there any solution to solve it?
...
anyone know how I would write that query with AR?
select *, (m.user_id=1) as member from band b join memberships m on m.band_id = g.id;
Thanks in advance.
...
I wanted to write a snippet of ruby that would take a string and output all possible permutations of capitalizations. Basically, I have a password that I remember, but I don't remember how it is capitalized.
I have the following so far:
def permute(str)
perms = Array.new
(2 ** str.size).times { perms << str }
perms.each_index d...
How can I make this code work?
class Meta
@array = [:a,:b]
def self.method_missing(name, *args, &block)
if @array.include? name
self.class.send(:define_method, name) do
do_call(name)
end
else
puts "[#{name.inspect}] ...
I have been spending some time creating what I called a framework.
It was aimed at the creation of quiz likes games. It was supposed to have two players syncronized and present them a question to solve, etc.
I would like it to be fully customizable so I tried to develop components that can be put in or out of the pages. In the end th...
The (Ruby Shoes) packaging solution from Hacketyhack.net doesnt work.
Can anyone point me to an alternative?
...
I'm working on a very limited environment and need a ruby (based) web server; currently I'm using Webrick but; I'm concerned about its oldness and lack of documentation. I can't install anything that requires building/compiling c/header files (like Mongrel or Thin). Are there any other alternatives for me?
edit: Upon request: The device...
Trying to implement a search logic search that uses associations with STI but I’m having a problem where it is not select the STI records as the subclass but the parent.
Example:
class Users
end
class Artist < User
has many :agents, :through => :agents artists
end
class Agent < User
has many :artists, :through => :agents artists...
I am just reading through Chris Pine's Learn to Program (The Ruby Series) 2nd Edition and it is one of the best programming books I have ever come across.
Unfortunately, he hasn't written (or I can't find) a book for Rails.
Does anyone know of any books that are of the same calibre and quality as Chris Pine's writing for Rails?
Thanks...
In Ruby (1.8.X)
Why does Object both inherit off Kernel and include it? Wouldn't just inheriting be enough?
irb(main):006:0> Object.ancestors
=> [Object, Kernel]
irb(main):005:0> Object.included_modules
=> [Kernel]
irb(main):011:0> Object.superclass
=> nil
Note in Ruby 1.9 the situation is similar (but a bit cleaner):
irb(main)...
Hi,
I'm looking for the best way to take a datetime string from MySQL, explode it in Ruby and return the month, date, and year in separate elements.
...
i get this once in a while when i use jruby to run ruby scripts.
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:117)
at test.__file__(test.rb:11)
at test.load(test.rb)
at org.jruby.Ruby.runScript(Ruby.java:592)
at org.jruby.Ruby.runNormally(Ruby.java:514)
at org.jruby.Ruby.runFromMain(Rub...
I have a Ruby script that's being used to do some API calls/screen scraping, but our main app is in PHP. Our PHP app is using shell_exec() to call the Ruby script.
The ruby script works great when called from the command line–but it will randomly exits early when called via PHP's shell exec.
Here's an example of the Ruby script:
#!/...
Is there a way to directly reference (using rails directly, without resorting to a lot of custom SQL) a relation that is nested behind a polymorphic relation? In the below example, is there a way to define a has_many relation in User that references LayerTwo?
I'd like to do (in User)
has_many :layer_twos, :through => layer_ones
but...
I am wondering what are the possible rich internet application solutions that goes well with ruby or if there is a GWT equivalent?
...