In the previous installment, we learned about two of Rails’ methods that help create forms, form_for and remote_form_for. Those methods dealt with forms primarily based on Model data. Today we’ll turn our attention to form_tag and form_remote_tag which create more generic forms not tied to Model data.

Tutorial after the jump…

Read the rest of this entry

I was confused for a pretty long time about how to create forms in Ruby on Rails. Since many (most?) Rails applications are tied to databases, it makes sense that many interactions with model data will be done via HTML forms. My problem though, was that there just seemed to be too many choices, and the choices are poorly named.

Tutorial after the jump…

Read the rest of this entry

RubyNoob Reborn!

June 28th, 2007

After months and months of neglect, primarily due to the fact that I’ve had tons of problems getting Typo to run properly on Dreamhost, I have finally revived RubyNoob running in Mephisto! RubyNoob is up and running on a slice from SliceHost, being served by Litespeed.

I’m planning on writing up some guides on how I did the transition from Typo and Dreamhost to Mephisto and Slicehost, but first I’d like to thank Paul over at UsefulJaja for creating the incredible tutorials that I followed in setting up my new slice.

As I’m writing this, the new RubyNoob is using the plain generic Mephisto theme. I’m planning on slowly evolving my own theme over the next few months. I’m hardly a web designer or expert in CSS, but it’s time that I learn and what I’d like to do isn’t really anything spectacular or complicated.

Since my last useful posts I’ve learned a lot of stuff about Ruby on Rails. I’ve added a full e-commerce solution to JoyLi.net by integrating it with Google Checkout. That was a great experience and I’ll be writing about that as well.

If you’re reading this, you’ve found your way to the new RubyNoob (or your RSS subscription actually figured out what happened and I’m amazed) and I’d like to thank you for stopping by. Let’s hope I keep the ball rolling from here on out!

Note: all comments since the migration have been given the date of the migration, sometime in June 2007. Please ignore all the comment dates.

Rails + Errors + FastGI == Bad

January 24th, 2007

One way to generate a lot of “500 – Application Failed” errors in Ruby on Rails applications running on Dreamhost is by throwing a lot of errors. Right now my newly downloaded Typo (supposedly the most recent stable version) is throwing some errors and this is, in part, causing RubyNoob to keep going down.

I’m investigating this to see what I can figure out. My advice is, if you’re running Rails on Dreamhost and you keep getting application failure errors, the first place to look is your production.log file. Make sure to clear up all errors first.

I’ll talk about what else you can do once I get RubyNoob a bit more stable.

Windows is Evil

January 24th, 2007

Simple lesson for other Ruby on Rails noobs – editting dispatch.fcgi in Windows and then uploading to your website may be hazardous for your site!!

Although I haven’t had other issues with doing so, after totally destroying RubyNoob over the past few days, I’m always going to do any editting of dispatch.fcgi through my Dreamhost shell! Apparently some invisible characters can get into your file and keep your site from starting up.

I’ve also updated to the latest and greatest typo, but in the process I’ve lost the comments for the 4 or 5 most recent posts – and that sucks. I’ll see what I can do to resurrect them – or at least the ones worth bringing back.

I have an interesting article coming soon about Dreamhost and Ruby on Rails and Applications failing to start. I’m going to try to make the changes I’ll be mentioning and we’ll see if RubyNoob becomes more stable.

The 20 Coolest Ruby Apps you’ve never heard of…

Actually, I have heard of a few of these. BillMonk is a pretty darned cool idea for the younger, poor college aged crowd. CommunityWalk is another of my favorites, but I didn't realize it was written in Rails.

Blogged with Flock

More fantastic resources

July 9th, 2006

19 Rails Tricks Most Rails Coders Don't Know" RubyInside.com does it again! This is a great list of Rails shortcuts that us mere mortals will probably come to rely on. Thanks guys!
16 RJS Resources and Tutorials for Rails Programmers This is a great list of resources for RJS stuff, not the least of which because it has a link here! And yes, I'm back (again)!
Setting up a link in your Rails app to allow your users to download any file is incredibly easy. Not just incredibly easy - OMGWTHBBQ easy! Stuff like this makes Rails so cool!

First, put the file out on your server. I put my "README.txt" file in a "files" folder like this: "rails/ appname/files/README.txt."

Next, set up a link in one of your pages:
1
2

<%= link_to 'Get Readme', :action => 'get_readme' %>
Finally, add the "get_readme" action method to your controller:
1
2
3
4

  def get_readme
    send_file("files/README.txt", :filename => 'yo_readme.txt')
  end
That's it! Now, whenever a user clicks the "Get Readme" link on your page, the file will be sent to the client. The :filename option simply allows you to suggest a name for the file to your users. I threw it in just to see how it works. I couldn't believe it was this easy, but sure enough, it is. Very cool.

There are other options like the :filename option which allow you to tell the browser what type of file to expect, how to display the file, and whether or not to stream the download. Streaming is turned on by default and allows downloading of very large files. All of these options go into the same line of code. Take a look at the article at this link.

As usual, expect a quick video demonstration of this posted later tonight.

Rails Custom URL Tutorial

May 18th, 2006

When my del.icio.us rails app finally goes live, one of the features it will have will be the ability for users to associate a retreived query with a keyword so that they can easily get back to it in the future.

For instance, let's say that I get a list of my del.icio.us links tagged with the word "ruby." I edit them in whatever way I feel like, and then save my creation along with a keyword that I choose - let's say "ruby" for simplicity.

I don't want my users to have full access to the admin sections of my application - they'll only have access to create and update their query results. So, I want to give them the ability to use their keyword as part of the url. So it'll be something like http://delipaste.com/saved/ruby.

Read the rest of this entry

Simple Rails RJS Tutorial

May 13th, 2006

"Write javascript without writing javascript!" It sounds so zen... There is no spoon. Ahem. One thing I've read about since I've started fooling with Rails, and especially since it was officially included in 1.1 is .rjs templates and how they allow rails developers to totally skip writing javascript code. It sounded just like something I ought to learn about and then write a tutorial on...

Read the rest of this entry
Here's some video of the app that I wrote using my delicious script, an ajax progress indicator and scriptaculous effects. It's not very exciting, but it does show the behaviors in a more explicit way than just reading about it. I have another video I hope to post soon where I go over the actual code a bit.

Please leave me a comment and let me know what you think!



Test
Thanks once again for inspiration to Brian Eng of Softies on Rails, here's my latest tutorial. Brian mentioned how easy it would be to add script.aculo.us effects to my little delicious app. And he was totally correct. What are script.aculo.us effects, you ask? Go check out this page. Click on each of the little demo boxes and watch the magic. Now say, "Holy crap! That's cool!" Then come back and I'll tell you how to add any of that to your Ruby on Rails app.

Read the rest of this entry
Ok, so my little del.icio.us app (click link to read about how I added Ajax functionality to a simple Rails app) is pretty cool, but it was missing one big thing. When the user clicks the "Get Results" link she has no idea that the page is communicating with the server. While the communication doesn't go on forever, an impatient user might click the link multiple times.

So, we need a way of letting the user know that something is happening and that they ought to wait a bit. Today, the standard seems to be an animated spinning icon:
This means we're waiting for a return back from the server: Spinner

Read the rest of this entry

RubyNoob gets all Ajaxy

April 23rd, 2006

Or:

"How I got some cool Ajax stuff to work with Ruby on Rails"

This weekend, my goal was to get my first original Ruby on Rails application working on my development box. I have achieved at least some sort of success! My app, such as it is, allows a user to enter a tag from her del.icio.ous account and then the app calls the del.icio.us REST API for that tag, strips out the html links and puts them into a text area. The user can then edit the text returned and save the tag/results combination into the database. It's not too exciting, but it's been a lot of fun to get together.

Read the rest of this entry