So, I'm sitting there on Friday evening working on a screencast introduction to attribute_fu, when Fabio Akita sends me an email to tell me he just created one for resource_controller! It was like he'd read my mind.
Fabio was nice enough to agree to let me put some title screens on his r_c screencast, but I couldn't seem to get it to export while still looking decent. So, here's the first episode of GiraffeCasts (for those of you who don't know, my company is called GiraffeSoft), and Fabio's awesome resource_controller introduction.

Episode 1: attribute_fu
Episode one is a quick walk through the basics of attribute_fu. Get it here.
As promised, here is the code from the screencast:
## _task.html.erb
<p class="task">
<b>Title:</b><br/>
<%= f.text_field :title %>
<%= f.remove_link('Remove') %>
</p>
## _form.html.erb
<div id="tasks">
<%= f.render_associated_form(@project.tasks, :new => 3) %>
</div>
<%= f.add_associated_link('Add Task', @project.tasks.build) %>
class Project < ActiveRecord::Base
has_many :tasks, :attributes => true
private
before_save :remove_blank_tasks
def remove_blank_tasks
tasks.delete tasks.select { |task| task.title.blank? }
end
end
To get attribute_fu:
$ piston import http://svn.jamesgolick.com/attribute_fu/tags/stable vendor/plugins/attribute_fu
Fabio's resource_controller Screencast
Fabio Akita gives an excellent tour of resource_controller, in screencast form. Get it here.
See Ya Next Time
That's all for today. Check back for more GiraffeCasts!


Great work James, both plugins are amazing. I hope both screencasts help people realize how useful they can be.
Nice job, quality screencasts are always welcome and helpful. From a fresh pair of eyes and ears, I think it moves a little quick. Sometimes code is being discussed at the same time it's written.
I know it's hard to gauge presentation speed when you've gone over the material a dozen times yourself, and it's just my observation; "too fast" will obviously vary from person to person. I can just rewind if I'm too slow! :)
the link "resource_controller" is wrong. Nice first screencast :)
Thanks for the comments guys - I appreciate the feedback. I'll definitely try to slow the next one down a little.
Also, the link is fixed :)
Very nice scast, Keep on the good work, Watch out Ryan bates!!!
omg! nice job James & Akita. You should put this on a dedicated site like Railscast, would be a hit.
You need some sort of feed for those, I want iTunes to auto-download them :)
Nice screencast and plugz!
I do have a couple o questions
Does attribute_fu work with polymorphic children?
In case it doesn't, lets say I want to have multiple belongs_to and have that task partial sitting in a shared directory. How would I override the default behavior?
I figured out #2.. using :partial as argument in addassociatedlink()
Also realized there is no polymorphs yet.. wonder how hard it would be to implement
hmmm..
I'm not sure what you mean about supporting polymorphic children.
It definitely supports has_many :as - or do you mean something else?
Ahh, you are right.. it does support!
The only thing that bugs me about this implementation is the repetitive before_save method that has to be pasted into every model.
Yeah, you could create a module, and just include it in various models.
Also, there will likely be some wrapping of that functionality in the next release.
James,
Can this be used to create multiple items of one model. Let's say a form to create multiple Projects instead of multiple tasks per project?
Malko - No, the plugin doesn't do that, sorry.
Congratulations: very impressive screencast !!!
attributes_fu hat similar problem like http://railsforum.com/viewtopic.php?id=803
def update ... respond_to do |format| params[:project][:tast_attributes] ||= {} if @project.update_attributes(params[:project]) ... end
James, this is extremely cool, thanks! I love resource_controller as well.. good stuff.
A very good screencast, but you are moving along a tad too fast for my taste. I'm used to Ryan Bates' style since I've watched quite a few of his screencasts lately, and I think he found the perfect pace -- so that would be my frame of reference here.
Other than that, great stuff. Pleasant voice to listen to, no mumbling and good video quality.