by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 19 2018 23:23
    kiddrew commented #14160
  • Nov 19 2018 23:23
    gmcgibbon synchronize #34468
  • Nov 19 2018 23:23
    kiddrew commented #14160
  • Nov 19 2018 23:12
    kamipo commented #34316
  • Nov 19 2018 23:10
    oniofchaos commented #34218
  • Nov 19 2018 23:09
    rafaelfranca synchronize #30320
  • Nov 19 2018 23:08
    oniofchaos commented #34236
  • Nov 19 2018 23:07
    rafaelfranca closed #34487
  • Nov 19 2018 23:07

    rafaelfranca on master

    Prevent TextHelper#word_wrap fr… Merge pull request #34488 from … (compare)

  • Nov 19 2018 23:07
    rafaelfranca closed #34488
  • Nov 19 2018 23:06
    rafaelfranca review_requested #34308
  • Nov 19 2018 23:05
    oniofchaos commented #34280
  • Nov 19 2018 23:01
    oniofchaos commented #34308
  • Nov 19 2018 22:52
    rafaelfranca synchronize #30320
  • Nov 19 2018 22:51

    rafaelfranca on master

    Indent guides as rails help com… Homogenize rails help output I… Merge pull request #34085 from … (compare)

  • Nov 19 2018 22:51
    rafaelfranca closed #34085
  • Nov 19 2018 22:51
    rafaelfranca commented #33643
  • Nov 19 2018 22:51
    rafaelfranca closed #33643
  • Nov 19 2018 22:50

    rafaelfranca on 5-2-stable

    Merge pull request #34106 from … (compare)

  • Nov 19 2018 22:49
    rafaelfranca synchronize #30320
Fintan Moloney
@Josebuendia

Are you not using an IDE?

I had been using Cloud9 which didn't give much info. I've downloaded the project and now its causing problems using it in VSCode. Need to change nokogiri but then I'd have to downgrade Ruby. I shouldn't have to lower my Ruby version.

William Flanagan
@wflanagan
Hey all, question. I'm trying to test my app "non-logged in" visitors. And, the problem I seem to be having, is that every request is treated like a new visitor. Seems to work fine in production. Any suggestions how to test using Minitest in a reliable way?
DanL12186
@DanL12186
people would really need to see specifics of your app/code
William Flanagan
@wflanagan
OK
William Flanagan
@wflanagan
Here's the code.. would love some feedback... https://gist.github.com/wflanagan/721de7ad59274099bf53eeb7a3e8e0ca
that has the current_helper as well the controller that renders content.
William Flanagan
@wflanagan
Nevermind. it was a "string" versus "number" problem.. thanks anyway
Joseph A.
@matedemorphy
OKD Minishift can be used like a development environment? like a Vagrant Box, let's say.
Joseph A.
@matedemorphy
or there is an alternative to Vagrant? I'm in a Windows machine and having problems to make actioncable works in a vagrant box
DanL12186
@DanL12186
This message was deleted
Tom Cardoso
@tomcardoso
Hi all, wondering if someone has a few moments to help me debug an ActiveRecord thing I'm having some issues with? I want to find an efficient way to make a slightly complex query involving database views
DanL12186
@DanL12186
Probably makes most sense to just post a screenshot with an explanation and see if anyone has any ideas
Tom Cardoso
@tomcardoso

Sure. I'm working with Textacular, which is a wrapper around pg_search. I'm using a form of multisearch using a database view, that looks at fields in two models: Case (case_number and short_title field) and CaseEvent (short_title and party_name). My database view joins the four fields into a view called Searches. Using textacular, I can do something like:

Search.web_search('richard')

=> #<ActiveRecord::Relation [#<Search searchable_id: 441, searchable_type: "Case", term: "R. v RODRIGUEZ, RICHARD">, #<Search searchable_id: 440, searchable_type: "Case", term: "R. v RODRIGUEZ, RICHARD">, #<Search searchable_id: 551, searchable_type: "Case", term: "OWIREDU, RICHARD">, #<Search searchable_id: 388, searchable_type: "Case", term: "R. v DESOUSA, RICHARD">, #<Search searchable_id: 387, searchable_type: "Case", term: "DESOUSA, RICHARD">, #<Search searchable_id: 923, searchable_type: "Case", term: "R. v KLEPACKI, RICHARD">, #<Search searchable_id: 620, searchable_type: "Case", term: "RICHARD v TREMBLAY">, #<Search searchable_id: 439, searchable_type: "Case", term: "R. v RODRIGUEZ, RICHARD">, #<Search searchable_id: 440, searchable_type: "Case", term: "RODRIGUEZ, RICHARD">, #<Search searchable_id: 802, searchable_type: "Case", term: "RICHARD, MATHIEU">, ...]>

But I want to go from that relation to a set of Cases, but still in relation form, as I'm later filtering and possibly sorting it. I can get the cases by doing:

Search.web_search('richard').preload(:searchable).to_a.map!(&:searchable)

=> [#<Case id: 621, case_number: "FC-13-00000891-0003", short_title: "ROWLAND v SPINDLER", case_type_id: 4, court_id: 1, created_at: "2020-06-02 20:45:47", updated_at: "2020-06-02 20:45:47">, #<Case id: 441, case_number: "471199820424100", short_title: "R. v RODRIGUEZ, RICHARD", case_type_id: 2, court_id: 1, created_at: "2020-06-02 20:45:37", updated_at: "2020-06-02 20:45:37">, #<Case id: 440, case_number: "47119982021900", short_title: "R. v RODRIGUEZ, RICHARD", case_type_id: 2, court_id: 1, created_at: "2020-06-02 20:45:37", updated_at: "2020-06-02 20:45:37">, #<Case id: 551, case_number: "FC-19-00000134-0000", short_title: "DE SOUSA v OWIREDU", case_type_id: 4, court_id: 1, created_at: "2020-06-02 20:45:46", updated_at: "2020-06-02 20:45:46">, #<Case id: 388, case_number: "47119982034700", short_title: "R. v DESOUSA, RICHARD", case_type_id: 2, court_id: 1, created_at: "2020-06-02 20:45:36", updated_at: "2020-06-02 20:45:36">, #<Case id: 387, case_number: "471199819808400", short_title: "R. v DESOUSA, RICHARD", case_type_id: 2, court_id: 1, created_at: "2020-06-02 20:45:36", updated_at: "2020-06-02 20:45:36">, #<Case id: 923, case_number: "211199820S208600", short_title: "R. v KLEPACKI, RICHARD", case_type_id: 2, court_id: 1, created_at: "2020-06-02 20:46:17", updated_at: "2020-06-02 20:46:17">,  etc…

But then it's an array, not a relation, which slows things down significantly (the :searchable attribute comes from Textacular itself). Is there any way to get from a Relation of Search objects to a relation of Case objects while keeping it in ActiveRecord form for possible database operations later in the same method?

DanL12186
@DanL12186
I don't think you can convert an array into an ActiveRecord Collection object
Tom Cardoso
@tomcardoso
Right, which I don't want to do anyway. I'd rather keep it in ActiveRecord
If I try to do a join I get a polymorphic error:
irb(main):122:0> Search.web_search('heather').includes(:searchable).joins(:searchable)
Traceback (most recent call last):
ActiveRecord::EagerLoadPolymorphicError (Cannot eagerly load the polymorphic association :searchable)
DanL12186
@DanL12186
Try the includes after the joins?
If this is all hyperspecific to Textaculuar/pg_search then forgive me, I've never used them
Tom Cardoso
@tomcardoso
I think it's more a polymorphism issue…
I guess I want to get from a relation of <Search> objects to a relation of its related <Case> objects instead
DanL12186
@DanL12186
oh
Tom Cardoso
@tomcardoso
So that's where I'm banging my head
DanL12186
@DanL12186
Long story short you're basically trying to get a Relation set of Parent.children from a result set of Parents, right?
Tom Cardoso
@tomcardoso
bingo
DanL12186
@DanL12186
I feel like the answer should be obvious, and yet.. lol. Maybe someone'll know.
Tom Cardoso
@tomcardoso
yeah… i've lost a day and a half to this
DanL12186
@DanL12186
Any chance it's a particular item that's failing with the includes and not all of them?
(additionally, this feels like a good time to register my grievance with the fact that it's Array#include? and ActiveRecord#include instead of Array#includes? and ActiveRecord#include...)
Tom Cardoso
@tomcardoso
i've no idea, honestly. i am super out of my depth here
DanL12186
@DanL12186
Just thought maybe you could test it with a query you know is only going to result in 1 or 2 records at a time. What the person was saying on that page was the query probably needed more information in order to eagerly load the association
My thinking may be poor, though :)
did you ever try the includes after the joins?
Tom Cardoso
@tomcardoso
i did… let me try again
yeah:
Search.web_search('heather').joins(:searchable).includes(:searchable)
Traceback (most recent call last):
ActiveRecord::EagerLoadPolymorphicError (Cannot eagerly load the polymorphic association :searchable)
Tom Cardoso
@tomcardoso
Ah, I figured it out! Took a totally different approach that ended up working. Thanks @DanL12186
DanL12186
@DanL12186
What was it?
lucas França
@z3ro-D4y
hi guys
im new here, in rubyon rails community
I want to learn Ruby, any advices where i can find good contents about it ?
DanL12186
@DanL12186
Rails Guides are good, Udemy Courses are also good
Fintan Moloney
@Josebuendia
Which is better to use Rails with, Docker or a Virtual Machine?
Kiti-nomad
@kiti-nomad
Could not find gem 'sqlite3 (~> 1.4) x64-mingw32' in any of the gem sources listed in your Gemfile.
Run bundle install to install missing gems.
how to fix it
Fintan Moloney
@Josebuendia
What happened when you ran bundle install?
Is the gem in your gemfile?
Kiti-nomad
@kiti-nomad
i am newbee
Fintan Moloney
@Josebuendia
Well check your gemfile and run that command.
Kiti-nomad
@kiti-nomad
i am tired