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
So, it wouldn't let me run migrations because of that prexisting table but I need to run migrations to run the server.
Kaia Leahy
@tenebrousedge
maybe you should tell rails to skip that step when it's generating the scaffold
Fintan Moloney
@Josebuendia
Oh, sorry, try this? But, if fixing the migrations really isn't an option, you can fake it in various ways. First of all, you could just comment out the migration methods, run rake db:migrate, and then uncomment (or revert) the offending migration.
Fintan Moloney
@Josebuendia
But I'm not trying to generate a model, the scaffolds appear to be there. I just need to run the server which requires DB: migrate.
Fintan Moloney
@Josebuendia
It looks like it might be easier to start a new application.
Fintan Moloney
@Josebuendia
So if I enter this command will the user be able to see the id in the user interface and perform CRUD functions to create a new user/case with a new id?
Daniel
@DanL12186
Please just Google, try it out, and follow the error messages.
Fintan Moloney
@Josebuendia

Okay, I'll try these commands again. See what happens. rails generate scaffold Customer name:string phone:integer
rails generate scaffold Cases topic:string created_at:datetime

Problem is, sometimes the error messages their meanings aren't as clear to me as they are to you.

Kaia Leahy
@tenebrousedge
it does help to read them though
matrixbot
@matrixbot
Stephen D Did you add the code in the migration that's needed to drop the tables?
Fintan Moloney
@Josebuendia
Got that sorted. Now I have this problem: ActionView::SyntaxErrorInTemplate in CasesController#index.
Is it because cases is a keyword in Rails? I mean, using the scaffold command and db:migrate command shouldn't lead to any errors.
matrixbot
@matrixbot
Stephen D There's a syntax error in your cases controller file
Stephen D in the index method
Fintan Moloney
@Josebuendia
Yeah, I think once it gets to the index method it gets confused as its a keyword. I'll undo those scaffolds and tables and change the name to issues.
matrixbot
@matrixbot
Stephen D I'm pretty sure cases isn't a reserved word
Stephen D case is
Fintan Moloney
@Josebuendia
The way the cases controller is generated by the scaffold creates a variable /array called case. See: <% @cases.each do |case| %>
<tr>
<td><%= case.case_id %></td>
<td><%= case.topic %></td>
<td><%= case.created %></td>
matrixbot
@matrixbot
Stephen D ah, that's the issue then
Fintan Moloney
@Josebuendia
So, I've been going through this tutorial: https://blog.engineyard.com/using-jquery-with-rails-how-to to try to the Single page app thing sorted. But it says "parsing error, unexpected token". The code: $(document).ready(function() {
$('[data-js-hide-link]').click(function(event){
$(this).parents('li').hide();
event.preventDefault();
});
}
Looks syntactically correct to me.
Tim Krins
@timkrins
@Josebuendia in your last post you are missing the final round bracket ).
Daniel
@DanL12186
Are you not using an IDE?
matrixbot
@matrixbot

Johan Smits > <@gitter_lorensonrails:matrix.org> Hallo everyone, I have a message error that I don't know how to resolve. I also didn't found anything useful on the internet that could help me. This is the message error that I get:

Looks like a missing require of a gem.

Johan Smits Or a the Class Stripe
Joseph A.
@matedemorphy
Is not possible to use Apartment Gem for multitenancy and ActionCable in Rails 6 yet, right?
Michael Lang
@mwlang
Are there any known issues with upgrading a Rails 4.x app from from either Ruby 2.1 or 2.2 to Ruby 2.5?
a link to relevant documentation would be highly appreciated as my Google-fu is failing me today.
Daniel
@DanL12186
It'll depend on your code. There's always deprecations between Ruby versions, so yeah, potentially. But unlikely anything that would be a disaster. AFAIK the only real guides are for upgrading Rails versions, not Ruby...
Michael Lang
@mwlang
nice trick with bundle update --conservative. That one's new to me.
Daniel
@DanL12186
me too ;)
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?
Daniel
@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
Daniel
@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
Daniel
@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?

Daniel
@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)
Daniel
@DanL12186
Try the includes after the joins?