Read my latest article: 8 things I look for in a Ruby on Rails app (posted Thu, 06 Jul 2017 16:59:00 GMT)

Microsoft called me today...

Posted by Tue, 28 Jun 2005 20:52:00 GMT

No seriously, a guy from Micro$oft called me today. I was a bit afraid at first, had to remind myself that yes, I run Linux and OSX, I’m safe… I think. ;-)

Actually, in late July, they are helping host Portland Code Camp 2005, which is basically 2 days of FREE developer conferences.. but in a classroom setting. It will be held at Reed College (where Lucas just graduated from). It’s typically, .NET, MS SQL, etc related… the main group behind it is the Portland Area .NET Users Group (PADNUG). Basically, a bunch of stuff that I’m generally not too involved with unless its assisting with a migration away from their platforms. ;-)

It turns out that there has been some buzz about the Ruby on Rails hype and they’re interested in having me (or someone) come and give a presentation at the event. I have not said an officially yes or no, as I’m supposed to be going down to California towards the end of the month to visit family.

While I was talking with the guy from Microsoft (they are covering the costs for the venue…), he asked if I knew of any body that might also be interested in speaking on subjects such as open source databases (mysql, postgresql, etc..), Python, etc. They want to keep things local… so if you’re in the Portland area, shoot me an email and I’ll put you in contact with the right guy to talk to.

One thing that kind of amused me was some content on their site.

To create a little structure, we’ve proposed a variety of one- and two-day tracks including Hobbyists, Mobile and Tablet PC, Architecture and Patterns, Databases, Web Development, Client Development, Games Development, Tools, Methodology, XML and Web, and “Alternative Lifestyles” (Ruby on Rails, Python, Squeak, etc.)


Heh, Alternative Lifestyles. Not the worst label.. but when I think about .NET versus Rails, I feel like those folks are the ones who enjoy the pain. ;-)

Is .NET a fetish and is Ruby on Rails a fad?

PostgreSQL vs MySQL with Rails

Posted by Sat, 18 Jun 2005 23:44:00 GMT

Every once in a while, there is a short debate about using MySQL or PostgreSQL with Ruby on Rails as a database server. If you know me at all, you’ll know that I am a strong proponent of using PostgreSQL. Putting some logic in the database is something that my last few jobs have completely trained me to do.

For example, I try to develop applications under the assumption that it will never be the only interface to the data set that it uses. In a way, I use the database as a part of the model and don’t put the reliance on the model in my Rails application.

For example, take the following example of updating a bunch of records that meet a certain requirement.

Items.find(:all, :conditions => "type_id='2'") do |item| 
    item.x = "foo" 
    item.save 
end

Is this method quicker than running a simple UPDATE query on the database? With a smaller data set, this might not be big enough of a concern. But, what if your database has a million rows that meets this criteria? Does it make sense to find them all first and then loop through the recordset one million times and call one million updates? A few problems might occur, one big potential issue is that it is likely that your application might go beyond the timeout of your server and there is no rollback with this transaction.

So, what is the best Rails-way to solve this problem?

If the request takes too long and times out, how do you ROLLBACK your updates automatically? I know how to do this with PostgreSQL (quite simply), but am curious as to how this is addressed by MySQL proponents.

Let’s take another scenario. Perhaps you have a table called foobars. Every time you INSERT or UPDATE this table, you want to add a record into table foobarlogs that shows what was added or what fields were specifically changed. With PostgreSQL, you could build a trigger that compares the existing record with the new values and then adds the differences into the foobarlogs table. This might not be something that people encounter, but for some systems, it’s vital that you know when something happened, by whom, and what exactly happened.

Step forward into the future. Client needs a new interface built for desktop usage. Yes, you could use Ruby with wxWidgets and build a nice multi-platform application. In your code, you deal with the same database. With your trigger in place, you don’t need to do anything but call it like you did with Rails.

Yes, MySQL is getting advanced features, but its still a while before you’re going to get to use pl/Ruby for building your database functions.

Wouldn’t this follow more along the lines of the DRY principal than doing this in the Rails code?

- A curious PostgreSQL-fan

PostgreSQL, all the features you need next year, available last year.

On a side note, here is a good explanation of how PostgreSQL is useful for certain application requirements.

Does AJAX break the MVC pattern?

Posted by Sat, 18 Jun 2005 22:28:00 GMT

A friend asked me earlier after he read some background on MVC... “According to the MVC pattern, a view should never know anything about the users input.”

He was reading this PDF.

Conversely, a view should never know about user input, such as mouse operations and keystrokes.

I can see his point, but not quite sure that with javascript, that this violates the MVC rule. Javascript always seems to be an exception with web development. (does it become its own controller?)

Thoughts on how to respond to him with a good answer?

It’s obvious that we use AJAX with controllers, but what about on a simple Toggle.display() ?

Playing with Rails Day projects

Posted by Sun, 05 Jun 2005 16:07:00 GMT

Woke up, Rails Day site was down. noradio on irc mentioned that the svn repos were up though. :-)

Earlier this morning, I checked out every Rails Day project and started picking random ones to try to play with. I showed people on #rubyonrails. Of about 30 that I tried to run, I had good experiences with about 5-10. It was surprising to see that a lot of people didn’t put a db schema file in db/. (which prevented me from getting too far)

I am going to tinker with more later, but had to get some of my own work done.

Some of the cool ones that I saw so far were, Sheets, Catfish, fischbowl (spelling), and there was one more but I don’t remember the name. I’ll have to look at them again. I was just picking random project #s and trying… so there are probably lots of them to see. :-)

What were are your favorites so far? project name and #:

Ruby FPDF on Ruby on Rails

Posted by Sat, 04 Jun 2005 13:24:00 GMT

3 comments Latest by sg Mon, 21 Aug 2006 08:57:06 GMT

I have been tinkering with Ruby FPDF for a client all night. I found the examples for it to lack in some real-world examples, so I have taken the example from the RubyOnRails wiki and added a bit more to it. I have added things like an image, links and made a generic letter template. (just an example). I didn’t get into the header/footer functions yet, may do that later.

If you are not sure how to use Ruby FPDF, check out the FPDF documentation.

Just download Ruby FPDF and unpack the archive in your libs directory.

To get Railst to load fpdf, I added this to environment.rb:

ADDITIONAL_LOAD_PATHS.concat %w(
  app
  app/models
[..snip...]
  lib/fpdf
).map { |dir| "#{RAILS_ROOT}/#{dir}" }.select { |dir| File.directory?(dir) }
At the top of my controller that uses this lib, I added:
require 'fpdf'

When I browse to this controller/method, I got this PDF to generate with this code.

  def pdf
    send_data gen_pdf, :filename => "robbyonrails-fpdf-test.pdf", :type => "application/pdf"
  end

 private
  def gen_pdf

    d = Date.today

    pdf=FPDF.new
    pdf.AddPage
    pdf.SetFont('Arial')
    pdf.SetFontSize(10)

    pdf.Image('/home/matchboy/logo2.jpg',10,8,86,0,'JPG')

    pdf.Cell(0,6, "PLANET ARGON", 0,1,'R')
    pdf.Cell(0,6, "2802 NE 57th Ave",0,1,'R')
    pdf.Cell(0,6, "Portland, OR 97213",0,0,'R')

    pdf.Ln
    pdf.Ln
    pdf.Write(5, "Jane Doe
123 ABC Street
Gilroy, CA 95020

#{d.month}/#{d.mday}/#{d.year}

Dear Jane Doe,

I just wanted to say...

Epsum factorial non deposit quid pro quo hic escorol. Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum. Defacto lingo est igpay atinlay. Marquee selectus non provisio incongruous feline nolo contendre. Gratuitous octopus niacin, sodium glutimate. Quote meon an estimate et non interruptus stadium. Sic tempus fugit esperanto hiccup estrogen. Glorious

Cheers,

Robby Russell
          ")
    pdf.Ln
    pdf.Cell(0,6, "PLANET ARGON", 0,1,'L',0,'http://www.planetargon.com/')
    pdf.Output
  end

Once again, the output. (click to view PDF)

It’s nothing special, but it’s just an example of how you can add a bit more than ‘Hello World’ to the top of a PDF. I’m still working on figuring out all the x/y stuff. Maybe I will post a better tutorial in the future with headers and footers.

Until then… have fun!

Rails Day, t-minus...

Posted by Wed, 01 Jun 2005 22:26:00 GMT

Casey on IRC asked what some cool gems that you could all use for your Rails Day projects. As I have said before, I will not be participating.. but I am looking forward to playing with the projects that everyone is going to work on. :-)

So, let’s make a list of cool gems that people could use.

gem install rails (obvious) ;-)

What gems do you find to be cool and useful?

Older posts: 1 ... 29 30 31 32