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...
Duration: 1:08 | Size: 1.3 MB
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.
Nobody takes you aside anymore
Print taught a generation when to stop. What we lose when the machines absorb the constraints that used to form us.
Your AI agents need a water cooler
Coordination is a property of the room, not the org chart. What that means when your coworkers are agents.
On the death of the author and the birth of the detector
Why worrying about AI authorship is lazier, and more prejudiced, than it looks.
The work of being available now
A book on AI, judgment, and staying human at work.
The practice of work in progress
Practical essays on how work actually gets done.
How to manage content for multiple clients without flattening their voices
How to manage content for multiple clients without their voices blurring into one house style: a workspace and a voice profile per client, batchable stages, and approval buffers.
Why does AI writing sound generic? It has nothing to work with
Why does AI writing sound generic? Because the model has none of your perspective, examples, constraints, or stakes to work with. The fix is interview-first, not better adjectives.
How to train AI to write in your voice, not your vibe
How to train AI to write in your voice isn't a prompt trick. It's a system: writing samples, interview answers, keep/avoid lists, revision loops, and approval gates.
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.
Place custom Rails routes first
Learn how to prioritize custom Rails routes for error-free routing and improved functionality in your web applications. Optimize your code now!
Ruby on Rails: Using a different controller with in_place_editor_field
Learn how to use in_place_editor_field in Rails with a different controller, ensuring seamless functionality across views and controllers.