Paul Welty, PhD WORK, BEING, AND STAYING HUMAN

In_place_editor with a collection in a partial in Ruby on Rails

Easily implement in_place_editor for collections in Ruby on Rails partials with this straightforward guide and troubleshooting tips. Save time and simplify...

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.

· ruby-on-rails

Featured writing

When your brilliant idea meets organizational reality: a survival guide

Transform your brilliant tech ideas into reality by navigating organizational challenges and overcoming hidden resistance with this essential survival guide.

Server-Side Dashboard Architecture: Why Moving Data Fetching Off the Browser Changes Everything

How choosing server-side rendering solved security, CORS, and credential management problems I didn't know I had.

AI as Coach: Transforming Professional and Continuing Education

Transform professional and continuing education with AI-driven coaching, offering personalized support, accountability, and skill mastery at scale.

Books

The Work of Being (in progress)

A book on AI, judgment, and staying human at work.

The Practice of Work (in progress)

Practical essays on how work actually gets done.

Recent writing

Reaction: Boredom is the new burnout, and it's quietly killing motivation at work

This article offers a fresh perspective on workplace dynamics, highlighting how boredom, often overlooked, can be as detrimental as burnout, and provides insights on redesigning work to enhance motivation and engagement.

AI Slop: The Hidden Cost of Poor Integration

This article challenges the notion that job crafting is the key to successful AI integration, offering a fresh perspective on the importance of a clear strategy to prevent chaos and enhance organizational efficiency.

Influence in the AI Era: Why Human Skills Still Matter

Discover why empathy and leadership are essential in the AI era, enhancing jobs and ensuring a human-centered future in a tech-driven world.

Notes and related thinking

Google Criticized for Privacy Issues

Explore the critique of Google’s privacy practices as Ian Hickson defends the company's intentions and highlights the impact of public skepticism.

Llama 2 avoids errors by staying quiet, GPT-4 gives long, if useless, samples

Discover how Llama 2 outperforms GPT-4 in generating reliable code, revealing crucial insights on the effectiveness of large language models.

NoMethodError (undefined method `finder') with Engines and Rails 2.2

Fix the NoMethodError with ActionMailer in Rails 2.2 by applying a simple patch. Save time and troubleshoot efficiently with our guide.