#RubyOnRails - 18 August 2018
« Back 1 day Forward 1 day »
[00:06:34] jeromelanteri: and ok, i have a template view with a list of articles, and a form for new article.
[00:07:36] jeromelanteri: the ajax mechanism on form new article is working fine (i mean... create.coffee is call and add a new row to the table list of article in the index html template view.
[00:09:31] jeromelanteri: but the index.coffee is running when call from kaminari pagination remote (index action through JS show by puma, then index.coffee is call) but nothing more happening... the params[:page] show value 2 (i do a puts params[:page] who show that: 1/ action is call, and 2/ parameter is read by index action)
[00:10:12] jeromelanteri: the id targets (1/ the list of articles and 2/ the pagination row from jaminari) are not updated
[00:11:07] jeromelanteri: an "alert" line in the index.coffee script file show that alert was never call but puma show no error and show that SQL from render code from index.coffee was run....
[00:12:03] jeromelanteri: also... i have a raijs-ujs error who is talking about: syntaxError expected expression got '<'
[00:19:41] jeromelanteri: and also, inside puma information, i see a line tell me that it rendering index.html.haml... but why ? just 2 lines up to this one it show that the call is for JS format, and not for HTML format... i also have a respond_to do |format| in the index controller who has to NOT rendering html when JS is call.
[00:27:37] jeromelanteri: if you would like something more for be inspired to help me, tell me what i can show more.
[01:01:05] auctumnus: hello! i'm getting an issue "undefined method `images' for nil:NilClass", here's the gist: https://gist.github.com/auctumnus/f279bdb2284fa4dff4da1e588b1c3205
[01:07:10] jqpl: auctumnus: the only place you're calling #images is on @reply, which is set from @post.replies.create, so is that method returning nil ?
[01:08:12] auctumnus: oh, it'd make sense that it'd be returning nil, the old replies from when i was testing before i added the ability to add them to posts dont have any images
[01:23:12] jeromelanteri: first of all... i do not understand why rails render a html when the call is for a JS format... someone can explain this please ?
[01:31:50] jeromelanteri: fryguy, i print controller code and coffeescript code up there, which one would you like to see ?
[01:46:08] fryguy: jeromelanteri: the code that drives the controller, or a console log of interacting with the controller via curl, or a failing test case in minitest or rspec
[01:47:07] jeromelanteri: fryguy, ok well... i'm going to open a bitbucket public repo for push the testcase code and show all of the simple code.
[02:05:20] jeromelanteri: when try to add jquery-rails, i have a little bit more luck (by little bit, i mean that an error about: '$ is not defined' diaspear for article.coffee code)
[02:08:22] jeromelanteri: fryguy, i call this js stuff from submit form button (for create JS call), and from kaminari pagination buttons (for index JS remote call).
[02:10:14] jeromelanteri: together make problems... i got some little luck with jequery-rails... but not to full luck. Actually, i'm thinking i'm doing something wrong so i'm beck to try with ariginal rails-5.2 included gems... but... 3 days of fight without any luck with AJAX.
[02:11:32] jeromelanteri: fryguy, and also thank you very much to try to help me, because actually you are the first one to try. Maybe ajax is a real mission with rails... i don't know.
[02:17:20] fryguy: depends on how the gem adds it, i'd guess it's .js.coffee, but see what the test tells you
[02:17:24] jeromelanteri: (i will also remove render layout: false and let only format.js... i was so confused that i tryed many things without undesrtand really what i have to know)
[02:18:18] jeromelanteri: fryguy, what make me surprised is that pemu show that index.coffee or create.coffe are executed together... and it reads the render part of theses script codes
[02:20:24] jeromelanteri: fryguy, also, "depend on how gem adds it" make me confused because i was expecting about a convention to follow... i try js.erb (without coffeescript code), and js (without erb extention), and coffee, and js.coffee, and only coffee... depend of jquery-rails gem prensent or not that change the comportment, but without it seems to be the same.
[02:23:52] jeromelanteri: fryguy, well, now i remove all rendert layout: false from format.js (create and index method together), and renamed create.coffee for create.js.coffee. Exactly the same problem happend. What i see is that in puma messages, without render layout: false, there is no more call of render html (that seems to be logic). but stay same error rails-ujs.
[02:33:52] jeromelanteri: fryguy, please, my code is very simple and i do push a full testcase. Could you try to use it ?
[02:36:58] jeromelanteri: fryguy, ok. thank to tryed to help a bit. if one day you have time for git clone and run this test case, maybe you will find what i'm doing wrong (because now, i'm thinking that if you use rails-5.2 with ajax without any problem... then my code has something wrong)
[02:38:29] fryguy: it's definitely your code, rails isn't released with some bug that's just like "oh, ajax doesn't work"
[02:40:27] jeromelanteri: fryguy, ok, but it is difficult when you follow the guide to be confronted directly with errors and no one tell you why when you ask (3 days to ask and fight with that also...)
[02:41:30] jeromelanteri: i also had to read comment here about someone who directly said that he doesn't want to "assist" (it is is word) someone who learn rails (so a beginner). Wow...
[08:42:46] Andr3as: morning.. i never created an admin section like this before.. so i made a namespace :admin and put my stuff in a "do / end".. routes are working fin, index actions too though i have a bit of a struggle with a "new" action...
[08:42:55] Andr3as: this is a gist https://gist.github.com/awunder/e143b80d85dd1e9a6feaea0b60513148 of it
[08:43:16] Andr3as: as a teaser, i am getting "NameError - uninitialized constant Admin::InstrumentTemplatesController::InstrumentTemplate:"
[09:23:17] Code_: Thanks - I can build CRUD without Scaffold in RoR. About 6 months in. I want to build a Book Borrowing app but not sure how to go about it.
[09:23:43] Andr3as: i have another one as well.. am using the responders gem with a "location" redirect.. i do it like this respond_modal_with @instrument_template, location: "/admin#instrument_templates"
[09:24:33] Andr3as: if i use a location "/admin" it does just fine "/admin#instrument_templates" isnt working though.. no errors either.. anyone an idea how to redirect to urls / paths like this?
[09:26:19] Code_: I have a User model a Book model. Books must be borrowed, how do I allocate a Book to a User and remove it from being able to be borrowed
[09:27:34] sevenseacat: so it sounds like you want another model in the middle - something like 'user X borrowed book Y for these dates'
[09:31:34] Andr3as: Code_: i'd go for the thing sevenseacat has mentioned.. let there be an entry for each occurence a book has been borrowed.. kinda l ike a "registration for borrowings"
[09:32:18] sevenseacat: Andr3as: I stopped using the responders gem many years ago, it was too magic for me
[11:34:28] chridal: When using webpacker my compiled application.js file is a lot shorter than the one in development
[11:34:55] chridal: Any thoughts? I tried unminifying it, and even then the ration was like 700'000 lines vs 300'000
[11:35:42] chridal: I'm not getting any errors during compilation, but if I include the minified file in production, nothing renders on screen.
[13:11:15] jeromelanteri: fryguy, well... i see that in fact, rails-5.2 doesn't works out of the box with ajax and jquery. That explain error about "$"... in fact, what the guide doesn't said is that rails-5.2 also need jquery. A "new" (again) way is to install it with yarn... and add it to applicaation.js BEFORE rails-ujs.
[13:12:25] jeromelanteri: guide should be updated for explain that also. And people there who want to help without help should be stop to be so strong with people who doesn't know and ask (because if they knew, they will not aska lso..)
[13:51:06] jeromelanteri: other tryed before you... 3 days to ask... big and wonderfull community there ! bravo and thank you very much.
[20:27:37] amperry: Hi folks, I'm getting an error that I have very little to go on, so as a workaround until I can fix that, I want to use either a cron job or scheduled rake task to check if the server is up, and if not, to restart it. I'm having bad luck with the cron approach, however, and I have no idea what a rake task would look like to do this.