Posted by Ben Reubenstein
Tue, 10 Jun 2008 01:47:00 GMT
After almost a year of collecting data and half a million results recorded,
Xcellent Creations, Inc. has released the next version of the iNetwork Test web application. The iNetwork Test web application for iPhone has been moved to
http://www.inetworktest.com/iphone_content. The main
iNetworkTest.com is now a portal to
Mobile Network Testing Results.
User's can now create an account which allows them to save all of their results and create a personal results map. This build out will also support new versions for the
Android platform and the
iPhone.
Posted in Ruby on Rails | Tags apple, iphone, network, speed, testing | no comments
Posted by Ben Reubenstein
Fri, 04 Jan 2008 17:50:00 GMT
In the beginning there was file_column. It was an excellent plugin for handling file uploads and image processing with the added bonus of being able to simply pass a file to it and have it work without a file upload via a form. One thing that file_column didn't do was fill in your db with file attribute goodness that could be used to create logic around a particular file. attachment_fu handled this along with the ability to use multiple image processors. For detailed info on attachment_fu, check out
Mike Clark's article.
In order to add some local_file_fu to attachment_fu so you can pass a local file directly to it, you have to take your local file and turn it into a temporary file that you can pass to attachment_fu's uploaded_data method. I altered the
solution outlined here for my solution.
1. Create a class in your models directory in a file called local_file.rb.
require 'tempfile'
class LocalFile
# The filename, *not* including the path, of the "uploaded" file
attr_reader :original_filename
# The content type of the "uploaded" file
attr_reader :content_type
def initialize(path)
raise "#{path} file does not exist" unless File.exist?(path)
content_type ||= @@image_mime_types[File.extname(path)]
raise "Unrecognized MIME type for #{path}" unless content_type
@content_type = content_type
@original_filename = File.basename(path)
@tempfile = Tempfile.new(@original_filename)
FileUtils.copy_file(path, @tempfile.path)
end
def path #:nodoc:
@tempfile.path
end
alias local_path path
def method_missing(method_name, *args, &block) #:nodoc:
@tempfile.send(method_name, *args, &block)
end
end
2. In order for attachment_fu to pass validations, you need to set the mime type of the file. This would usually come from the form when it is uploaded, but since we are using a local file, we'll set our mime types in environment.rb. At the end of the file add the various mime types you will need:
@@image_mime_types ||= { ".gif" => "image/gif", ".ief" => "image/ief", ".jpe" => "image/jpeg", ".jpeg" => "image/jpeg", ".jpg" => "image/jpeg", ".pbm" => "image/x-portable-bitmap", ".pgm" => "image/x-portable-graymap", ".png" => "image/png", ".pnm" => "image/x-portable-anymap", ".ppm" => "image/x-portable-pixmap", ".ras" => "image/cmu-raster", ".rgb" => "image/x-rgb", ".tif" => "image/tiff", ".tiff" => "image/tiff", ".xbm" => "image/x-xbitmap", ".xpm" => "image/x-xpixmap", ".xwd" => "image/x-xwindowdump" }.freeze
3. Now in your code that creates the model that has_attachments you can simply do the following:
model = Model.new()
model.uploaded_data = LocalFile.new(FULL_PATH_TO_FILE)
model.save
As always, comment on anything you have issues with or suggestions.
Posted in Ruby on Rails | Tags attachment_fu, rails | 6 comments
Posted by Ben Reubenstein
Tue, 31 Jul 2007 13:04:00 GMT
Today I was doing some massive migrations that rocked the very foundations of an app I am working on. Problem was that during the migration I was moving objects around the database and validations were failing for my saves. To get some debugging going, I started out trying to write to the logger, with some good ol' logger.debug, but that does not work within a migration. To output information in a migration, use puts. So for example to see all the errors that prevented object g from being saved:
class MyMigration < ActiveRecord::Migration
def self.up
g = G.new(:name => "name" )
if g.save
#More object manipulation here
else
g.errors.each do |x|
puts x
end
end
end
def self.down
#Down Method Code Here
end
end
Posted in Ruby on Rails | Tags activerecord, debug, migrations, rails | 2 comments
Posted by Ben Reubenstein
Thu, 07 Jun 2007 11:33:00 GMT
When Google announced the new
Google Co-op, which includes custom search engines, I did not immediately see the value. I wish I understood this services huge value sooner! I was trying to configure a reliable Apache with Mongrel Clustering setup, but was having a very tough time finding information. The Mongrel-users mailing list is hosted using Mailman, which does not have an obvious search function. When querying Google I was getting those results mixed in with the rest of the web. This is a perfect example of how a custom search engine can narrow your scope and get you the right answer fast. I setup a simple custom engine that just searched http://rubyforge.org/pipermail/mongrel-users/. I used the same query I had been using within Google, but this time found my answer almost immediately.
I have started another Ruby on Rails dedicated search engine that I hope to refine as I find more sources of information. This one searches the major Rails/Ruby mailing lists, the wiki, and the main site. I have left the search engine open, so if you have a site to contribute, feel free!
Ruby On Rails Custom Search
Mongrel Mailing List Search
Posted in Announcement, Ruby on Rails | Tags apache, coop, google, mongrel, rails, ruby, searchengines | no comments
Posted by Ben Reubenstein
Sat, 17 Jun 2006 01:15:06 GMT
So I did end up turning in an app for the Rails Day Contest! I thought with moving there was no way, but I spent about 3 hours and created a very simple app I call, My Name Is URL... You can watch the competition real time here and see my progress here. Good Night, and Good Luck everyone who is participating in Rails Day!
Posted in Ruby on Rails | no comments
Posted by Ben Reubenstein
Thu, 04 May 2006 21:39:00 GMT
I just updated benr75 to run off of the Typo trunk. The move went relatively smoothly, but with a few minor issues. The first issue was solved pretty quickly as DeLynn Berry upgraded recently too, and posted this fix for many older templates that were not using the right method to render the sidebar.
My next issue I must say got my heart racing for a minute. The database changed a great deal since the last release, and the migration for some reason did not set the type or name fields for my pages. After some quick SQL, I changed the NULL type fields to Page in the Contents table, and fixed the NULL name fields back to their original name.
As a bonus the commenting is now working properly!
Posted in Announcement, Ruby on Rails | 3 comments
Posted by Ben Reubenstein
Thu, 04 May 2006 16:47:58 GMT
Jens-Christian just posted an excellent PDF he titles, Ruby on Rails Short Reference on his InVisible Blog. It contains a good chunk of information on many aspects of Ruby on Rails including rake, generators, models, controllers, and views.
Posted in Ruby on Rails | no comments
Posted by Ben Reubenstein
Tue, 28 Mar 2006 09:24:00 GMT
Ruby on Rails 1.1 was released today. If you already have Rails installed, simply run:
gem install rails --include-dependencies
rake rails:update
It is also recommended that ruby is upgraded to 1.8.4. On my windows box this caused all kinds of issues with how tab characters were interpreted. I posted this tip to the Rails mailing list:
Hello All ~
As suggested I upgraded Ruby to 1.8.4 along with Rails. My Linux
boxes have been running 1.8.4 and haven't complained about my source.
On the Windows version however, if you start to see errors like:
Invalid char `\002' in expression
parse error, unexpected tIDENTIFIER, expecting kEND
Go through your code and replace your tabs with spaces. I use
EditPlus and you can configure the tabs to use spaces. This solved my
problem.
~ Ben
Also, if you're running Lighttpd, be sure to upgrade.
Posted in Ruby on Rails | no comments
Posted by Ben Reubenstein
Fri, 20 Jan 2006 16:33:00 GMT
DeLynn has finnally released his Userstamp Plugin for Rails. In a nutshell if you place fields in your database named updatedby and createdby it will fill the values in for you when the particular model is saved with the current user. Obviously there are some more technical things to do to get it to work, but I tested it in my app and it works as described. Instructions and source can be found here:
http://www.delynnberry.com/pages/userstamp
Posted in Ruby on Rails | no comments