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 …
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:
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):
Nested resources in Ruby on Rails are sort of neat, but they are a pain to implement. What’s more, I have to ask myself, why bother?
If a resource has a unique identifier id, then why would you need to call its parent resource to call it? The unique identifier is enough. And what resource doesn’t have a unique id these days?
On my work blog (http://www.synaxisworks.com/blog/), I used to use the default “?p=post-number” format, and I wanted to change to a more SEO-friendly format. I setup Dean’s plugin. The first problem is that I didn’t know what to put for the “old permalink structure”. I tried a million combinations of text, regex, and Wordpress codes to try to get it to match the …