ActiveScaffold custom action_link that should respond like update

Posted by doug316 on Stack Overflow See other posts from Stack Overflow or by doug316
Published on 2010-05-07T00:01:17Z Indexed on 2010/05/07 0:08 UTC
Read the original article Hit count: 362

I have a custom action link which is :inline and :post. It's a quick-link to update an attribute, and that part works just fine. After the action, my intent is to respond just like it was an update, so the row is re-rendered in the index.

After the record is updated in my controller action, I call

respond_to_action(:create)

Just like in the create method in active scaffold. It seems like the content of the javascript response is returned correctly to the client, however, the problem: The content-type of the response header is "text/html" instead of "text/javascript", unlike with an actual update. So the JS is not executed and the row doesn't update.

I can't figure out what the difference could possibly be here, I've traced extensively and even have replaced the respond_to_action with:

respond_to do |format|
  format.js do
    render ...
  end
end

And it still won't set the content-type like every other action in the app.

Anybody have a clue here? Something in active scaffold must be overriding the content-type and I can't figure out what it might be.

Surprising this isn't documented, this doesn't seem like an unusual use-case, making an action a slave to the update re-render.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about activescaffold