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

use eval for determing the self.class.name useful when this is used in an abstract class #123

Merged
merged 1 commit into from
Nov 26, 2014

Conversation

flarik
Copy link
Contributor

@flarik flarik commented May 30, 2014

When using acts_as_list in an Inheritance class like this:

class SuperClass < ActiveRecord::Base
  self.abstract_class = true
  acts_as_list
end

class Child < SuperClass
  self.table_name = 'the_table_i_really_want'
end

The output of the method acts_as_list_class is set to the name of the parent class (::SuperClass) instead of the child class (::Child). By using eval the correct Class name is returned. I'm using the variable @acts_as_list_class so eval doesn't slow things down.

Maybe there is a better (rails?) way of doing this then eval. But is works.

reference: http://api.rubyonrails.org/classes/ActiveRecord/Inheritance/ClassMethods.html

swanandp added a commit that referenced this pull request Nov 26, 2014
use eval for determing the self.class.name useful when this is used in an abstract class
@swanandp swanandp merged commit 921eefe into brendon:master Nov 26, 2014
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

Successfully merging this pull request may close these issues.

2 participants