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_resourse isn't called unless I override update #2457

Closed
jtvjt opened this issue Sep 5, 2013 · 5 comments
Closed

update_resourse isn't called unless I override update #2457

jtvjt opened this issue Sep 5, 2013 · 5 comments

Comments

@jtvjt
Copy link

jtvjt commented Sep 5, 2013

If I do the following, update_resource gets called.

ActiveAdmin.register User do
  actions :index, :show, :edit, :update
  controller do
    def update_resource(object, attributes)
      puts "==================before update====================="
      debugger
      object.update_attributes(*attributes)
      puts "=================after update====================="
    end    
    def update(options={}, &block)
      super do |success, failure| 
        block.call(success, failure) if block
        failure.html { render :edit }
      end
    end

However if I leave off my overridden "update", I don't get a call to update_resource. Any reason you can think of why that would be the case?

@seanlinsley
Copy link
Contributor

I just tried this myself and am not having this problem. What version of Active Admin, and Rails are you using?

@jtvjt
Copy link
Author

jtvjt commented Sep 6, 2013

Rails 3.2.13 on ruby 1.8.7
gem 'activeadmin', '~> 0.6.0'

Active Admin is mostly unusable for us in our project I think. Too many of our crazy patches conflicting with modern rails code.

I'll leave this open in case anyone has thoughts and close it in week if no one else has any thoughts.

@seanlinsley
Copy link
Contributor

I have no idea what crazy patches you think Active Admin has. If you don't like it, don't use it.

By the way: you desperately need to upgrade to Ruby 1.9 or 2.0. Ruby 1.8 has been officially deprecated and is no longer being maintained.

In fact, it's possible that that's the problem, since blocks in Ruby 1.8 have a different arity.

@jtvjt
Copy link
Author

jtvjt commented Sep 9, 2013

No I meant our crazy patches, not active_admin's. I want to use it as it makes the admin code so easy!

Thanks for the info about arity. That seems like a likely culprit.

@seanlinsley
Copy link
Contributor

Ah, my bad :]

Hopefully you get this figured out. By the way, this is what I was referencing when I mentioned arity: #1930 (comment)

So Inherited Resources itself checks the arity of the block passed. I seem to remember a problem / hack used for Ruby 1.8

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

2 participants