Pages

Showing posts with label partials. Show all posts
Showing posts with label partials. Show all posts

Sunday, February 20, 2011

#RubyOnRails and partial forms

I'm working on some exercises in the Ruby on Rails Tutorial book. I noticed a lot of duplication in my new and edit views, so I thought I'd try and make it more DRY. I knew I'd need a partial, but I hadn't written one for a view yet.

I'd heard good things about the #RubyOnRails IRC channel, so now was a good time to try it out. I had to download an IRC client for my MacBook, and chose Colloquy. In almost no time, I got enough help to implement my partial. (If you aren't familiar with it in Rails 3, you can see my solution here.) I don't know why it tripped me up so much. I finally got the second argument right in the form_for correct and used it as a local variable in the submit line so that the button has the right text. And all my rspec tests pass.