Skip to content

Conversation

@brookzhang
Copy link

If dimension.nil? , query should be " dimension is null ", not "dimension = '' ".

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both the old version and this one don't work with inheritance because the polymorphic association will use the class.parent_name instead of class.name

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a better approach would be let active record help us, something like:

  val = rates.select_value("count(*) as cnt").where(dimension: dimension, rater_id: user_id)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code is much simpler and will work find with model inheritance

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