Hello,
I have always been taught that storing objects in a session was a bad idea. Instead IDs should be stored that retrieve the record when needed.
However, I have an application that I wonder is an exception to this rule. I'm building a flashcard application, and the words being quizzed are in a table in the database whose schema ...
So I understand you aren't supposed to to directly subclass Fixnum, Float or Integer, as they don't have a #new method. Using DelegateClass seems to work though, but is it the best way? Anyone know what the reason behind these classes not having #new is?
I need a class which behaves like a Fixnum, but has some extra methods, and I'd lik...
Does anyone have a code sample that shows how to use the Win32 function CopyFileExW in ruby? The difficulty i am having is declaring the 'ProgressRoutine' call back function correctly without getting a segfault.
I can use CopyFileW without issue, but CopyFileExW is causing grief.
require 'windows/error'
require 'windows/wide_string'
re...
I have no rails enviroment but I want to use cruisecontrol.rb as my Continous Integration enviroment.
After following the instrcution from http://cruisecontrolrb.thoughtworks.com/documentation/getting_started and then
./cruise start
I got the error here: (sorry, but the formatter is better than posting it here directly)
http://pas...
I am working on a content management application in which the data being stored on the database is extremely generic. In this particular instance a container has many resources and those resources map to some kind of digital asset, whether that be a picture, a movie, an uploaded file or even plain text.
I have been arguing with a colle...
I've set up a new Rails 2.3.2 app and added the Basecamp API ruby wrapper to my /lib directory from here:
http://developer.37signals.com/basecamp/basecamp.rb
In my application_controller.rb I have created the following method to enable calls to Basecamp:
def basecamp_connect
Basecamp.establish_connection!('xxxxxx', 'xxxxxx', 'xxxxx...
I'm writing my first rails plugin and could use a little help. In a very simplified way, I'd like to do allow the developer to specify a value which I can count through a rake task. I'm thinking of something like this...
class User < ActiveRecord::Base
monitor "Users", count
monitor "Active Users", count("activated_at != NULL")...
I have a framework written in Ruby that needs to be converted into Groovy.
It does not use anything outside of core ruby, but a lot of meta programming.
Are all the same basic features supported by Groovy and is the changeover complicated?
...
I have the following models:
class Person < ActiveRecord::Base
has_many :accounts, :through => :account_holders
has_many :account_holders
end
class AccountHolder < ActiveRecord::Base
belongs_to :account
belongs_to :people
end
class Account < ActiveRecord::Base
has_many :people, :through => :account_holders
has_many :acco...
I want to get a xml file, which I can request by an http request into an object.
I'm looking for something similar to this (in a controller):
@ticket = request "http://example.com?ticketid=1234"
http://tickets.com?ticketid=1234 returns an XML (tickets.com is not the site the app is running on).
I then want to parse @ticket, to get th...
Every html document is an xml document. In the current project there are a lot of html tags which are not properly closed. This is a ruby on rails application. I want to put an after filter which will parse the whole html output and will raise an error if the parsing detects that it is not a well-formed document.
In this case well-forme...
We are writing a Rails application that is using CouchDB as its data store. We're BDD/TDD'ing with RSpec and Cucumber, which is using WebRat for webpage testing
I'm trying to remove ActiveRecord as one of the resources that is being loaded by rails but its causing the cucumber tests to fail. I've removed all references that I can find...
What is the best way to push data from a server written in Sinatra (ruby) to a client? Think similar to a chat room, but without ajax polling every 2500ms. I know of Juggernaut in rails, but was curious about Sinatra.
Thanks,
-Tom
...
Python and Ruby are usually considered to be close cousins (though with quite different historical baggage) with similar expressiveness and power. But some have argued that the immense success of the Rails framework really has a great deal to do with the language it is built on: Ruby itself. So why would Ruby be more suitable for such a ...
I have a Cucumber step for my Rails application:
Then /^I should be redirected to the sign in page$/ do
assert_equal 302, @response.status
end
But that @response object is the one returned by my Controller, and it's the Rack middleware that sets the status to what I expect it to be. How can I get at the response as returned from th...
If I have an object with a collection of child objects in ActiveRecord, i.e.
class Foo < ActiveRecord::Base
has_many :bars, ...
end
and I attempt to run Array's find method against that collection:
foo_instance.bars.find { ... }
I receive:
ActiveRecord::RecordNotFound: Couldn't find Bar without an ID
I assume this is because A...
I'm experiencing something that I can't explain with Rails 2.3.2. I've created a new app, with one controller and one action to try narrowing this down. My entire controller is as follows.
class LinesController < ApplicationController
def show
respond_to do |format|
format.html { render :text => proc {|response, output|
...
The ECMAScript working group has started working on the next edition of the language. What can they learn from Ruby?
...
Hello,
I would like to know how to explicitly set a timeout for the Ruby DBI ODBC driver, when connecting to SQL Server. I would like long running queries to simply timeout and cancel themselves, saving further server resources and Rails processes.
This was happening while we were using the ADO based Ruby driver, but now that we've sw...
I have written a method to calculate a given percentile for a set of numbers for use in an application I am building. Typically the user needs to know the 25th percentile of a given set of numbers and the 75th percentile.
My method is as follows:
def calculate_percentile(array,percentile)
#get number of items in array
return nil i...