Skip to main content
Paul Welty, PhD AI, WORK, AND STAYING HUMAN

· ruby-on-rails

Getting a remote form to submit within a partial collection when any select changes in Ruby on Rails

Streamline remote form submissions in Ruby on Rails with dynamic select changes using JavaScript callbacks for smoother user interactions.

Duration: 1:29 | Size: 1.7 MB

This one is harder than it seems. But, I figured out a way. The trick and breakthrough came from Teflon Ted.

With a regular form, you could do this in your select statement:

:onChange=>"this.form.submit();"

This won’t work with a remote form, because the submission is not handled with the submit method but rather within the JavaScript callback in onsubmit. So, with a remote form, you have to change it to this:

:onChange=>"this.form.onsubmit();"

So, here is my code.

<%- remote_form_for
  :user,
  user,
  :url=>{:action=>'update_remote', :id=>user.id},
  :html=>{:id=>'form_'+user.id.to_s},
  :loading=>"Element.show('spinner_"+user.id.to_s+"'); Form.disable('form_"+user.id.to_s+"')"
  do |f|
-%>

<%= f.select
  :project_id,
  Project.find(:all).collect{|p| [p.name,p.id]},
  {:include_blank=>false, :selected=>user.project_id},
  {:onChange=>"this.form.onsubmit();", :id=>'user_project_id_'+user.id.to_s}
%>

<%- end -%>

	>%= image_tag 'spinner_arrows.gif' %< Saving...

Note that this is in a partial that gets iterated over a collection. So, I have to give everything a unique id in the HTML. Also, note that this includes the user of a spinner to show activity is taking place. I also like to disable the form temporarily to make sure nothing else gets selected. I don’t have to hide the spinner or reactivate the form because when the table row gets regenerated via RJS, it goes back to the default condition.

The agent-shaped org chart

Every real org has the same topology: principal, role-holder, specialists. Staff AI maps onto it, node for node, and the cost collapse shows up in the deliverables that were always just human-handoff overhead.

AI as staff, not software

Two frames for what AI is doing to work. The tool frame makes tools smarter. The staff frame makes roles unnecessary. Those aren't the same product, the same company, or the same industry.

Knowledge work was never work

Knowledge work was always coordination between humans who couldn't share state directly. The artifacts were never the work. They were the overhead — and AI just made the overhead optional.

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.

The lede does the work

A skill correctly stated 'default to standing down.' The bots over-applied it for most of a Saturday — citing the rule while real work sat in the queue. Six skills got rewritten after I noticed the lede was doing all the behavioral work, and the rest of the prompt was just commentary.

What stays in the tick when events catch the rest

Today I shipped an event-driven version of myself. Then I hit the part that wouldn't decompose, and the surprise was that 'wouldn't decompose' splits into three different reasons.

Routing isn't discoverability

I built three different routing mechanisms today before noticing the user didn't need any of them. Routing is how the message reaches the recipient. Discoverability is how the recipient knows there's a message at all. The two get conflated all the time.

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.

Rails + sugarcrm - an alternative approach

Discover a faster, simpler way to connect Rails with SugarCRM by accessing the database directly, avoiding slow API calls for seamless synchronization.

Rails + sugarcrm + soap - get a list of sugar accounts into Rails as an array

Integrate SugarCRM with Rails using SOAP to effortlessly sync company names and streamline your project management workflow.