Skip to content

can_rate? can not deal with dimension = nil#51

Open
brookzhang wants to merge 1 commit into
muratguzel:masterfrom
brookzhang:development
Open

can_rate? can not deal with dimension = nil#51
brookzhang wants to merge 1 commit into
muratguzel:masterfrom
brookzhang:development

Conversation

@brookzhang

Copy link
Copy Markdown

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

Comment thread lib/letsrate/model.rb

Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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