Polymathic

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


Ruby on Rails: Using a different controller with in_place_editor_field

I don’t know why this took a while to figure out, but it did. If you are using the stock Rails in_place_editor_field, you know it looks like this in the controller:

in_place_edit_for :user, :name

And like this in the view:

<%= in_place_editor_field :user, :name %>

This works fine so long as you’re rendering from the users controller. But, what if this view is a partial inside a different controller’s view? In that case, what gets called is not “/users/set_user_name” but “/othercontroller/set_user_name”. And, of course, it fails because there is no method (dynamic or otherwise) like that there.

The solution is easy, but the documentation isn’t helpful. You need to alter the view to be like this:

<%= in_place_editor_field :user, :name, {}, :url=>{:controller=>'users', :action=>'set_user_name', :id=>user.id}} %>

Discover more from Polymathic

Subscribe to get the latest posts sent to your email.



2 responses to “Ruby on Rails: Using a different controller with in_place_editor_field”

  1. Thanks! It would be helpful if the plugin documentation was longer then two lines — this code really helps!

  2. […] working. The first problem was the InvalidAuthenticityToken and the second issue was that I use a different controller, but now it works […]

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