I have a "tree-like" structure to my database in an app I am writing so that:
training has_many class_times
and
class_time has_many reservations
Is there a way to look up all reservations under a a given training? I could iterate through all of class times/add a foreign key, of course, but for some reason I have this little voice...
I want to remove the ":" from the output of the rails time_select helper. The helper seems to output this automatically when the minutes select box is built.
Any ideas?
Thanks!
...
Hi,
I am trying to check if a file exists in my rails application.
I am running ruby 1.8.6 and rails 2.1.2 with windows XP.
So, the problem is that the FileTest.exists? method doesn't seem to be working. I have simplified the code to this point :
if FileTest.exists?("/images/header.jpg")
render :text => "yes"
else
render...
I'm looking for a fast and reliable way to read/parse large PDF files in Ruby (on Linux and OSX).
Until now I've found the rather old and simple PDF-toolkit (a pdftotext-wrapper) and PDF-reader, which was unable to read most of my files. Though the two libraries provide exactly the functionality I was looking for.
My question: Have I ...
... or alternatively an Array which prevents duplicate entries.
Is there some kind of object in Ruby which:
responds to [], []= and <<
silently drops duplicate entries
is Enumerable (or at least supports find_all)
preserves the order in which entries were inserted
?
As far as I can tell, an Array supports points 1, 3 and 4; while a Se...
I'm thinking no, but hope to be corrected.
http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol
i.e. i'm simply looking to a batch read of ~1000 users via one query, instead of making ~1000 separate queries.
Update:
Okay, it helps to read the spec:
http://tools.ietf.org/html/rfc2254
: )
...
I currently use TextMate for all my Rails development, and I like it very much, but I wonder if I'm missing anything by not using an IDE. Has anyone switched from using TextMate or another powerful text editor to a Ruby IDE? Am I missing anything?
...
The business I work for is an on-line retailer, I'm currently working on a project that among other things involves calculating the customer prices for products. We will probably create a service that looks something like...
public interface IPriceService
{
decimal CalculateCustomerPrice(ISupplierPriceProvider product);
}
public inte...
I just came across an odd method in some Ruby code, and I'm wondering if I'm missing something fundamental. It looks like this:
def funny
!funny
end
What would this possibly return?
...
I'm parsing a csv file and trying to send it to a table with fewer fields than the original csv file. How do I remove those extraneous commas that are left over if I set the extra fields to nothing?
Here's the original csv format:
columns => id,first_name,last_name,phone,fax
sample row => 1,ben,tomas,5555555,6666666
Here's the final ...
I am new to ruby and looking for a way to create a "payload" of random binary data.
def payload_grow(payload_stack)
payload = payload_stack
valid_chars = ("a".."f").to_a + ("0".."9").to_a
length = valid_chars.size
hex_code = ""
hex_code << valid_chars[rand(length-1)]
hex_code
payload = payload + '0x' + hex_code + hex_code
...
I'm am an experienced developer in other languages like C#, VB.net and C++, but a real newbie in Ruby. What Ruby book do you think should I read first?
...
Hi, I am working on a testing framework for the software that my company writes. Our product is web based and After I run a RESTful request I want to process the results. I want to be able to have activerecord type validations in each command class so that after it is run the results are automatically tested against all the "validation...
I would like to write a script that takes one argument that might look like this:
abc(ag)de*
a, b, c are literal characters.
(ag) means "an 'a' or a 'g'".
* means any one letter or number.
I want the script to create an Array of all the possible strings the input could represent. (The purpose is to check if they're available domain...
Splats are cool. They're not just for exploding arrays, although that is fun. They can also cast to Array and flatten arrays (See http://github.com/mischa/splat/tree/master for an exhaustive list of what they do.)
It looks like one cannot perform additional operations on the splat, but in 1.8.6/1.9 the following code throws "unexpected ...
Some content in my page is loaded dynamically with the use of this code :
javascript_tag( remote_function( :update => agenda_dom_id, :url => agenda_items_url(options), :method => :get ) )
When it outputs in the browser, it comes out as this :
new Ajax.Updater('agenda', 'http://localhost:3000/agenda_items?company=43841&amp;history...
As I understand it, the Sinatra framework, unlike Rails, does not provide an ORM. In that case, how do you talk to a DB in a Sinatra app? Or is Sinatra only for apps that don't use a DB?
...
After I generate a scaffold, Rails gives me the ability to POST to items.xml which will create a new item. A GET to items.xml will simply list them all. Where does Rails specify which method in the controller (create or index, respectively) will be called, based on the type of action I am performing?
More specifically, POST calls method...
I'm working on a project that involves some scripting and data storage. The database that I have available to me is MS Sql Server and it is on a windows platform.
Despite this I'm looking to leverage Ruby to write the script, specifically JRuby. There are a couple of reasons for this
I would like to leverage Prawn to create pdfs
...
Hi,
I have designed an application consisting of 20+ tables, and utilizing Ruby on Rails.
I am using an authentication system for users to login. I want to display to the user, when he logs in, information related to him that can be found across many tables, between these tables there are all the possible relationships. How can I accomp...