I need to access a legacy relational database via ActiveRecord and that database uses a column named "object_id" as a primary key in a table. Most things work but when I try specify a custom SQL query for an association (see below) ActiveRecord respectively the Ruby interpreter always retrieves the object_id of the Ruby base "Object" ins...
I found this add-on for the Money gem which updates from the ECB European Central Bank (updates its rates every 24 hours) but I'm unsure how I should go about caching in my rails app which uses multiple currencies.
http://github.com/RubyMoney/eu_central_bank
eu_bank ||= EuCentralBank.new
eu_bank.update_rates
#Rails.cache.fetch('rates',...
I am trying to run Rails3 on XP Profesoinal and following the tutorial here http://railstutorial.org and am receiving the following errors all the time, even trying to return static pages. The message is the procedure entry point rb_str2cstr could not be located in the dynamic link library msvcrt-ruby191.dll
Also, the page gives a runti...
So it turns out mailers hate loop inside of them. So here's my loop.
- for ["love", "hate", "war"].each do |f|
= f
Which returns this went sent through actionmailer in rails 2.3.5 :
promotion_reminder.html.haml:17: syntax error, unexpected ';', expecting tCOLON2 or '[' or '.'
...ry_temp));}\n", 0, false);end;_hamlout.push_text(" ...
Does anyone have or know of a Ruby script that converts text to html?
Example:
I have a file that contains the following text:
Host Name
Info1
Line1
Info2
Line2
I want to have ruby convert it to the following html output
Host Name
Info1
Line1
Info2
Line2
I tried running RedCloth but got the following error:
The progr...
I am new to Ruby, and have a gem that I am making to interact with a JSONRPC API and basically all calls and responses are similar enough, that every API call can be handled with one function, like:
Module::api_command('APINamespace.NamespaceMethod')
but I would like to also (for convenience sake) be able to do:
Module::APINamespace.N...
I am trying to capture the identity of a gallery so that I can create a form based around that particular gallery.
So I put together a select form, and threw an attr_accessor in my controller.
But its failing from all sorts of directions, and I figure its a problem with my syntax. Any whiz's know this?
model
attr_accessor :existing_g...
Ruby's duck-typing is great, but this is the one way that it bites me in the ass. I'll have some long running text-processing script or something running, and after several hours, some unexpected set of circumstances ends up causing the script to exit with at NoMethodError due to a variable becoming nil.
Now, once it happens, it's usua...
does anyone know if open flash plugin for rails supports stacked area chart
could anyone point me to a working example of stacked area/area chart
thx
...
Is there any gem for ruby (i want to use it in a rails app) that does somethink like Twitter Stream API. Keep the http conection opened and send information in real time based in a query or events.
...
I am trying to run daemon process using daemon-spawn gem.
Here is the code for delayed_delta daemon process
#file - script/dj
#!/usr/bin/env ruby
# -*- ruby -*-
require 'rubygems'
require 'daemon-spawn'
RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
class DelayedJobWorker ENV['MIN_PRIORITY'],
:max_prior...
I want to read data records from a non-seekable stream in Ruby. I want to leave it up to the user whether the current record should be skipped or read. Usually you would include Enumerable and provide the necessary methods for it to have an iterator in Ruby, but in my case data can be skipped and only one iteration is possible, so I'm no...
Is there a way to raise an event in C# from an external application? In particular from Ruby? I have need to cause something to happen in C# from a rails application.
...
I have a voting system with two models: Item(id, name) and Vote(id, item_id, user_id).
Here's the code I have so far:
class Item < ActiveRecord::Base
has_many :votes
def self.most_popular
items = Item.all #where can I optimize here?
items.sort {|x,y| x.votes.length <=> y.votes.length}.first #so I don't need to do anything ...
I have a model (called Test):
property :id, Serial
property :title, String, :length => 255, :required => true
property :description, String, :length => 255, :required => true
property :brand, String, :length => 255, :required => true
property :link, String, :length => 255, :required => ...
I've got the following Ruby script:
class Server < GServer
def initialize
super(10001)
end
def serve(io)
while true
io.puts `ps -o rss= -p #{$$}`.to_i
end
end
end
server = Server.new
server.start
while true
sleep 10
end
When I open a connection to the server, it shows increasing memory usage over ...
I am working with a MySQL database that has capitalized table/field names like Users, Institutions, etc. Because the operating system of the database host is Linux, identifiers (like the table names) are treated as case sensitive. So, failing to capitalize a table name will result in a table does not exist error.
The problem I am trying...
The following code opens a text file does a little regex to match names and numbers. I do an IF so that I only match numbers greater than 0. When I try to puts the name and number, I only get the numbers and the name have become nil. If I puts the names (variable a) before the if statement, it is there. What am I doing wrong?
nf = File....
Could you tell me whats the best practice to create has_one relations?
f.e. if i have a user model, and it must have a profile...
How could i accomplish that?
One solution would be:
# user.rb
class User << ActiveRecord::Base
after_create :set_default_association
def set_default_association
self.create_profile
end
end
Bu...
I have a few Rails 3 apps deployed to Heroku that need to share some business logic. Apparently, although Heroku's Bundler support is pretty solid, it can't yet pull from a private Github repo. So instead I'm building a couple of gems, vendoring them into each app, checking them into git, and pushing them up with the rest of my code.
Th...