Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Action doesn't work for STI models #52

Closed
tkieft opened this issue May 18, 2011 · 5 comments
Closed

Update Action doesn't work for STI models #52

tkieft opened this issue May 18, 2011 · 5 comments
Assignees
Milestone

Comments

@tkieft
Copy link

tkieft commented May 18, 2011

When you edit a model that implements single-table inheritance, the updates are not saved

@gregbell
Copy link
Contributor

Thanks. We should definitely add STI models to the test suite to make sure we have everything working correctly.

@gregbell
Copy link
Contributor

@tkleft We implemented some cukes to test STI and they all seem to pass. Could you please post the stacktrace and relevant code of the issue you had?

@tkieft
Copy link
Author

tkieft commented May 27, 2011

I actually don't get an error....everything goes well, but the object is never updated.

I patched the update_resource action to do this to fix the problem:

controller do
def update_resource(object, attributes)
object.attributes = params[object.class.to_s.underscore]

  run_update_callbacks object do
    save_resource(object)
  end
end

end

Perhaps it could be fixed upstream too by passing the correct attributes into the function.

Are you able to repro this on your end?

On May 25, 2011, at 7:56 PM, gregbell wrote:

@tkleft We implemented some cukes to test STI and they all seem to pass. Could you please post the stacktrace and relevant code of the issue you had?

Reply to this email directly or view it on GitHub:
#52 (comment)

@tkieft
Copy link
Author

tkieft commented May 27, 2011

Ah...just looked at your cuke. I think it doesn't cover the case I was using. Let me put what I was trying to accomplish in terms of your models: User and Publisher.

I only have "User" registered with ActiveAdmin, not "Publisher," and I was trying to update a "Publisher" by going to /admin/users/:id/edit, and then save the form. Does that make sense?

@Hakon
Copy link

Hakon commented Jun 25, 2011

say you have the models

    class ArticleCategory < Category; end;

and register the active admin panel like this:

when you update an instance of ArticleCategory the form sends an article_category => { :name => "test" } where active_admin expects category => { :name => "test" }.

you can fix this by adding :as => :category to the form.

        f.inputs :name
        f.buttons
    end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants