Polymathic

Digital transformation, higher education, innovation, technology, professional skills, management, and strategy


In_place_editor with a collection in a partial in Ruby on Rails

It seems like it would take a lot of work to get the in_place_editor to work in a partial on a collection, but it does. (It took me a lot of time to figure this out, but maybe I’m just more than average dense.) The best post to-date on this is at we eat bricks.

Just add the usual in the controller (user_controller.rb):

in_place_edit_for :user, :name

And, of course, the method:

def edit
  @users = User.find(:all)
end

Then, in the main view (edit.rhtml):

<%= render :partial=>'user', :collection=>@users %>

Then, in the partial (_users.rhtml):

<%= in_place_editor_field :model, :column %>

At first, this won’t work. You will get an error that says “Called id for nil, which would mistakenly be 4 — if you really wanted the id of nil, use object_id” on the line containing the “in_place_editor_field”.

It turns out this is a bug, and there is a workaround. Just add this at the top of your partial:

<%- @user = user -%>

I hope this helps someone save some time.


Discover more from Polymathic

Subscribe to get the latest posts sent to your email.



6 responses to “In_place_editor with a collection in a partial in Ruby on Rails”

  1. Thanks for the mention:-)

    Looks like we both are exploring innards of Ruby on Rails. I’ll be sure to keep an eye on your blog.

    Best of luck!
    Jamie

  2. Thanks v much for this – saved me hours :):):)

  3. Thanks! This helped a LOT!

  4. Zaphod Beeblebrox Avatar
    Zaphod Beeblebrox

    I saved a lot of time !!! Thanks

  5. Anko Painting Avatar
    Anko Painting

    Thank you!!!!!!!!!!!

    This would have taken me ages to work out!

  6. Yes Yes!!!
    It rocks for me, saved me a lot of googling time, wonderfull !

Leave a Reply

Your email address will not be published. Required fields are marked *

About Me

Visionary leader driving digital transformation across higher education and Fortune 500 companies. Pioneered AI integration at Emory University, including GenAI and AI agents, while spearheading faculty information systems and student entrepreneurship initiatives. Led crisis management during pandemic, transitioning 200+ courses online and revitalizing continuing education through AI-driven improvements. Designed, built, and launched the Emory Center for Innovation. Combines Ph.D. in Philosophy with deep tech expertise to navigate ethical implications of emerging technologies. International experience includes DAAD fellowship in Germany. Proven track record in thought leadership, workforce development, and driving profitability in diverse sectors.

Favorite sites

  • Daring Fireball

Favorite podcasts

  • Manager Tools

Newsletter

Newsletter