Merge Request #72

Closed
softwarepublico/softwarepublico!72
Created by Daniela Feitosa

Replace scope by class method to avoid conflict

It was raising the error "You tried to define a scope named "like_search" on the model "SoftwareInfo", but Active Record already defined a class method with the same name."

On Rails 4.1 "scope" raises on "dangerous" name conflicts: https://github.com/rails/rails/commit/7e8e91c439c1a877f867cd7ba634f7297ccef04b

Assignee: Antonio Terceiro
Milestone: None

Closed by Daniela Feitosa

Changes were not merged into target branch

Commits (1)
  • It was raising the error "You tried to define a scope named "like_search"
    on the model "SoftwareInfo", but Active Record already defined a class
    method with the same name."
    
    On Rails 4.1 "scope" raises on "dangerous" name conflicts:
    https://github.com/rails/rails/commit/7e8e91c439c1a877f867cd7ba634f7297ccef04b
    Daniela Feitosa
     
2 participants
  • 75e3b052e046e34cbb10917c5f9901d7?s=40&d=identicon
    Antonio Terceiro @terceiro

    I think the right fix in this case is to rename the scope, and not turn it into a class method. when you chain scopes you get a single SQL query at the end, that's not always the case with class methods.

    Choose File ...   File name...
    Cancel
  • 0743c2eb05e68c92baa5f8c498995a20?s=40&d=identicon
    Daniela Feitosa @daniela

    Vou fechar esse MR. Essa solução (não ideal) foi aplicada em outro commit: 6f2cc74ea7def2454531baebab64f1a4127150f9

    No futuro, para melhoria do desempenho, pode ser feita a refatoração com a solução ideal.

    Choose File ...   File name...
    Cancel
  • 0743c2eb05e68c92baa5f8c498995a20?s=40&d=identicon
    Daniela Feitosa @daniela

    Status changed to closed

    Choose File ...   File name...
    Cancel