Hi,
i have a macruby application that leaks gigs of memory. Ruby is for the logic stuff and accesses some Objective-C classes of mine, to access functions like Accessibility-API and making some screenshots and process them via CIImage.
Having ruby and Objective-C code, which one handles the memory?
As far as i know, ruby collects its ...
I know you can view all possible rake tasks by typing
rake -T
But I need to know what exactly a task does. From the output, how can I find a source file that actually has the task? For example, I'm trying to find the source for the db:schema:dump task.
...
I am using Single-Table Inheritance (STI) on one of my models for a Rails App and I am having problems storing model objects on a constant. I have isolated the problem into a sample project and submitted it to GitHub: http://github.com/fcoury/rails-sti-caching
What I am trying to do is loading a model instance (in this case a Music mode...
Hi All,
I have a method in a rails helper file like this
def table_for(collection, *args)
options = args.extract_options!
...
end
and i want to be able to call this method like this
args = [:name, :description, :start_date, :end_date]
table_for(@things, args)
so that I can dynamically pass in the arguments based on a form commit...
What's the difference between the class and type methods in Ruby? I've noticed that type works to find the type of some classes but not others.
...
I need to implement login velocity checking for a web service. The service is in ruby and the database is MySql.
I can imagine bad ways to do this. For example, have a table that stores every login attempt's time and whether or not it was successful, and every time the user tries to log in, query that table for the last n login attemp...
I'm using Ruby on Rails to build a simple application to keep track of a shop's opening and closing times and its appointments, and I'm having some trouble validating the appointments against closings in the shop's schedule.
I've been using Runt to compose the schedule. For example, if the shop is open Monday morning from 9am-12pm clos...
Is there a way for something to raise and exception that does not descend from Exception?
What I'm trying to avoid is something like:
require 'timeout'
begin
timeout(1) {sleep(50)}
rescue StandardError => e
puts e.message
end
I know I can catch this with 'rescue Exception' or more drastically, 'rescue Object', but that seems a li...
A good friend just sent me the following email
My father is putting together a proposal for a local college to start a center of innovation and technology. As part of that, he’s proposing they teach web design and web development. My question is in your opinion what are the “industry standard” tools for both web design and web develo...
Im using the Active_Search plugin to try and add some simple search features to my app, it works OK when their it is found somethind in the DB but if i simply run a search with no input then it gives me the error message "ActiveSearch::EmptyTermError".
How do i make the search action return the correct values (which it can do), but also...
How can I bring my RubyCocoa application to the front? Basically I want to acheive the same result as the applescript line:
tell application "Whatever" to activate
...
I just read this as a requirement on a job listing:
Aware of the pitfalls of code like: User.find(:all).each
and knew instantly I was unqualified for this job because for the life of me, I don't understand what the problem is . . .
Is it design related? Store the database request in a variable and THEN iterate over it?
Is it dang...
Lets say I have a model called Recipe. Each Recipe has several photos, a PDF file and a video. Is there a plugin out there that lets me have something as simple as Recipe.photos, Recipe.photos.first.filename, Recipe.pdf.filename, Recipe.video.filesize and so on?
...
Hello everyone,
I need to write a little ruby function that does word wrapping. I have got the following function :
def word_wrap(text, line_width)
if line_width.nil? || line_width < 2
line_width = 40
end
text.split("\n").collect do |line|
line.length > line_width ? line.gsub(/.{1,#{line_width}})(\s+|$)/, "\\1\n").strip :...
Running this code:
n = 4 * 1000 * 1000
fn = (((1 + Math.sqrt(5)) ** n) - ((1 - Math.sqrt(5)) ** n)) / ((2 ** n) * Math.sqrt(5))
puts fn - 1
I get the warning
Bignum out of Float range
How can I fixed my code to solve this error?
Since ruby is dynamically typed, I don't know how. Thanks a lot.
...
I am trying to use the paperclip plugin to let users choose an avatar pic, upload and then store it. I cant seem to get this working.
I have generated the three fields:
add_column :users, :avatar_file_name, :string
add_column :users, :avatar_content_type, :string
add_column :users, :avatar_file_size, :integer
add_column ...
I have a RESTful Rails application with a resource called "Foo". I'm trying to use REST Client to do a put:
resource = RestClient::Resource.new 'http://localhost:3000/foos/1', :user => 'me', :password => 'secret'
resource.put :name => 'somethingwitty', :content_type => 'application/xml'
But my app raises:
ActionController::InvalidAut...
Hello,
I want to display "tips" on my page that changes every say 30 seconds. The results from the "find" method in rails is not ordered by ID. It will be ordered by another column.
What is the best way fetch "next" value. Is there a way to get number of row in result set and then find by next row id?
Thanks,
Tam
...
I really must be missing something here. Say I have a module MyModule. I dynamically load classes into it. How can I get a list of the classes defined within its namespace?
Example:
def load_plugins
Dir.glob(File.dirname(__FILE__) + '/plugins/*.rb') do |f|
MyModule.class_eval File.read(f)
end
# now how can I find the new cla...
guys i am having problems when trying to retrieve record from the database when the start_day and the end_day is equal, if i want to see the record of maybe: "from" 6 may 2009 To 6 may 2009. it doesn't give me the record and is there in the database it only give me the record if a type "From" 06 may 2009 To 7 may 2009. and my code is.
...