« Back to channel list

#RubyOnRails - 29 June 2017

« Back 1 day Forward 1 day »
[00:00:47] Psy-Q: has joined #RubyOnRails
[00:06:36] tfitts: has joined #RubyOnRails
[00:08:38] jhfisc: has joined #RubyOnRails
[00:21:52] Rodya_: has joined #RubyOnRails
[00:23:48] p8m: has joined #RubyOnRails
[00:28:54] jottr: has joined #RubyOnRails
[00:29:35] tanuki: has joined #RubyOnRails
[00:30:15] swrh: has left #RubyOnRails: ()
[00:33:04] r3vDev: has joined #RubyOnRails
[00:33:25] brent__: has joined #RubyOnRails
[00:35:35] umaaji: has joined #RubyOnRails
[00:55:01] mr-spoon: has joined #RubyOnRails
[00:56:00] sevenseacat: has joined #RubyOnRails
[01:09:12] mices: has joined #RubyOnRails
[01:09:24] mices: on facebook, are events just types of posts?
[01:10:09] mices: like a musician posting an appearance alert on facebook do you think they have a sepsarate event model or event is just a type of post
[01:14:29] patarr: has joined #RubyOnRails
[01:15:20] ur5us: has joined #RubyOnRails
[01:23:06] rfoust: has joined #RubyOnRails
[01:23:59] brent__: has joined #RubyOnRails
[01:29:51] jottr: has joined #RubyOnRails
[01:35:45] havenwood: mices: A profile has locations. A facebook event has locations and rsvp states. An event membership has rsvp states. Something like that. But this is the Rails channel! Don't copy facebook's schema anyhow.
[01:36:31] Technodrome: has joined #RubyOnRails
[01:58:18] irishfromua: has joined #RubyOnRails
[02:03:38] irishfromua: has joined #RubyOnRails
[02:16:59] hadricus: has joined #RubyOnRails
[02:17:49] umaaji: has joined #RubyOnRails
[02:30:58] jottr: has joined #RubyOnRails
[02:37:10] Jameser: has joined #RubyOnRails
[02:46:52] patarr: has joined #RubyOnRails
[02:51:23] delgiudices: has joined #RubyOnRails
[03:01:50] quazimodo: has joined #RubyOnRails
[03:08:05] Jason: so i'm building a little todo list, mostly using the standard scaffolds
[03:08:15] Jason: let's say i want to add a view for todos that are not marked as complete
[03:08:34] Jason: how would you recommend doing that? the way i'm thinking of doing it seems really redundant
[03:08:49] sevenseacat: how are you thinking of doing it?
[03:10:55] Jason: sevenseacat: well
[03:11:16] Jason: sevenseacat: i was thikning of adding a method to my todos controller
[03:11:37] Jason: def update
[03:11:48] Jason: err. def incomplete
[03:12:47] sevenseacat: sounds good so far, creating a new action
[03:13:14] Jason: sevenseacat: sorry, got kind of sidetracked..
[03:13:20] Jason: sevenseacat: def incomplete
[03:13:32] Jason: sevenseacat: @Todo.where(done: false)
[03:13:43] jhfisc: has joined #RubyOnRails
[03:13:45] Jason: and then another erb file to render
[03:13:59] sevenseacat: sounds like exactly what I would have recommended
[03:14:05] Jason: seems pretty redundant since all I really want to do is filter what's shown on the index page
[03:14:13] sevenseacat: then you can reuse the same view
[03:14:24] sevenseacat: just give it a different list of todos to render
[03:15:06] Jason: sevenseacat: so i'd format.html { render: "todos/index" } with a filtered @Todos?
[03:15:07] sevenseacat: thinking at it from a URL perspective, you could set up a route like /todos/incomplete that points to your new incomplete action
[03:15:28] sevenseacat: or you could use a get parameter and reuse the index action, ie. /todos?only=incomplete (or similar)
[03:15:41] Jason: i was thinking about doing the latter
[03:15:50] sevenseacat: either would be just fine
[03:15:57] Jason: hmmm. let's think
[03:19:09] Jason: sevenseacat: so i've put this in my index method: @todos = current_user.todos.all.where(params[:only])
[03:19:19] jhfisc: has joined #RubyOnRails
[03:19:30] Jason: though actually that doesn't seem right
[03:20:02] sevenseacat: `where` takes a hash of field/value pairs - do you have a field on your todo that says whether or not its complete or not?
[03:20:07] sevenseacat: oh right, you said done: false
[03:20:13] Jason: done is a boolean
[03:20:16] Jason: sevenseacat: i think i've got it
[03:21:24] Jason: sevenseacat: so question - let's say my query key/value is now ?done=false or done=true
[03:21:33] cam27: has joined #RubyOnRails
[03:21:35] Jason: i've got this in my index method: if params[:done] ...
[03:21:49] Jason: i'm concerned this only checks for the presence of a done key
[03:22:28] sevenseacat: it doesn't - it checks the value of the key (which will be nil if the key doesnt exist)
[03:22:58] Jason: so i could potentially have ?done=false, so i want `if params[:done] == true` ...
[03:23:58] sevenseacat: so you want to do the filtering only if the key exists, right, regardless of its value?
[03:24:48] Jason: sevenseacat: originally yes, i've since changed my mind: now i've got /?done=true, /?done=false, or /
[03:25:12] Jason: when done is true, only show done todos, done is false only show incomplete todos, and in the absence of the done key, show all
[03:25:17] sevenseacat: sounds like the same thing :)
[03:25:36] jhfisc: has joined #RubyOnRails
[03:25:49] Jason: let me pastebin this, i've got a solution but it looks quite redundant
[03:26:29] sevenseacat: would something like this work? https://gist.github.com/sevenseacat/c41406f568d0035d2c88081f0d0fa56a
[03:26:58] Jason: that was the stupidly simple solution i was thinking of
[03:27:20] Jason: sevenseacat: i've got `if`, `elsif`, and `else` as of right now, quite ugly
[03:28:16] sevenseacat: you may want to add another condition on the `if` in case someone tries to do like `?done=hello`, or convert the value into a boolean
[03:28:56] zacts: has joined #RubyOnRails
[03:31:40] jhfisc: has joined #RubyOnRails
[03:31:43] jottr: has joined #RubyOnRails
[03:32:24] Jason: sevenseacat: was reading the rails docs and came up withs
[03:32:30] Jason: sevenseacat: came up with* https://gist.github.com/jasonharrison/db5628584bea6889b147a7278844e87b
[03:33:18] Jason: seems overly complex to me, though, hah
[03:33:20] matthewd: Why would you need to do that? :/
[03:33:54] sevenseacat: I've seen that used to do things like convert '0' and '1' to true and false, I dont think it would be necessary for this case
[03:34:33] Jason: matthewd: i suppose you're right, worst that will happen if someone tries to inject something other than true/false is it'll 500 or return no todos
[03:35:00] sevenseacat: I think for this case the ruby trick of using a !! would work, ie. !!params[:done]
[03:35:33] Jason: i would have never thought of that
[03:35:35] Jason: that's a great idea
[03:35:36] matthewd: sevenseacat: It'll be a string "false" though
[03:35:37] sevenseacat: https://stackoverflow.com/a/3994065/560215
[03:36:11] matthewd: But I thought where did the conversion automatically
[03:36:26] sevenseacat: but if they pass in something thats non true/false, eg. 'hello'
[03:36:33] sevenseacat: you dont really want to do where(done: 'hello')
[03:37:08] sevenseacat: the db would have a big sad i think
[03:37:28] Jason: i tested it out of curiosity, just returned []
[03:37:30] sevenseacat: or is AR smart enough to handle it?
[03:37:50] sevenseacat: Jason: what SQL got run? (the logs in your terminal should show the query)
[03:37:59] Jason: Todo Load (0.3ms) SELECT "todos".* FROM "todos" WHERE "todos"."done" = ? LIMIT ? [["done", "hi"], ["LIMIT", 11]]
[03:38:01] Jason: => #<ActiveRecord::Relation []>
[03:38:17] Jason: so it's still wasting resources on a pointless query, though
[03:38:39] matthewd: I'm actually not sure how to read that tbh :P
[03:39:37] jhfisc: has joined #RubyOnRails
[03:39:46] matthewd: I thought it did the cast through AMo::Type.. maybe the bind value is logged pre-typecast?
[03:41:03] sevenseacat: its also not really a pointless query - it does have to load todos at some point
[03:41:08] sevenseacat: or attempt to
[03:44:54] jhfisc: has joined #RubyOnRails
[03:44:59] Jason: sevenseacat: hmm. i'm getting some weird SQL
[03:45:04] Jason: sevenseacat: https://gist.github.com/jasonharrison/5b7b239406c7116b28500233c02d20c8
[03:45:12] Jason: Todo Load (0.3ms) SELECT "todos".* FROM "todos" WHERE "todos"."user_id" = ? AND "todos"."done" = ? [["user_id", 1], ["done", "t"]]
[03:45:28] sevenseacat: that looks fair
[03:45:35] sevenseacat: whats weird about it?
[03:45:42] Jason: "done", "t" ?
[03:45:56] sevenseacat: some db engines store true/false as 't'/'f' internally
[03:46:34] Jason: sevenseacat: it seems to be doing it regardless of the query string if `done=` is present in the url
[03:46:37] matthewd: Presumably the fact it'll do that for false would qualify as weird ;)
[03:46:46] Jason: and only retrieving trues :P
[03:47:05] sevenseacat: well, doing that for false would be very weird yes
[03:47:13] Jason: that is indeed what it appears to be doing
[03:47:37] sevenseacat: which makes sense based on what matthewd said earlier - params are received as strings, so it will get 'true' or 'false'
[03:47:49] sevenseacat: and both of those will equate to true with a !!
[03:47:56] agent_white: has joined #RubyOnRails
[03:47:57] sevenseacat: so my idea was wrong :(
[03:48:02] Jason: that makes sense :p
[03:48:07] Jason: http://imgur.com/kdJJxVq
[03:48:57] Jason: so we're back to the drawing board
[03:49:14] Jason: i mean, i know *a* way to accomplish what i want, but it'll be really redundant and ugly
[03:49:44] matthewd: params[:done] != "false" ?
[03:49:55] matthewd: or == "true", depending on which you want to use for unexpected values
[03:51:04] jhfisc: has joined #RubyOnRails
[03:51:42] Jason: matthewd: so i want /?done=true to only show done: true, /?done=false to only show done: false, and anything else to show all
[03:52:07] Jason: i suppose i could do if/elsif/else, but yeah, i'm concerned it looks ugly
[03:52:26] sevenseacat: so back to my original suggestion, of adding another condition to the `if`
[03:52:36] matthewd: if params[:done].in? %w(true false)
[03:52:53] sevenseacat: eg. if params.has_key?(:done) && %w(true false).includes?(params[:done])
[03:53:04] sevenseacat: that would work too, I always forget that it can go the other way now
[03:58:48] jhfisc: has joined #RubyOnRails
[04:04:47] jhfisc: has joined #RubyOnRails
[04:06:28] Jason: that does indeed work, thanks much matthewd and sevenseacat
[04:06:34] Jason: at least the include?
[04:06:54] Jason: so now it appears that, as we said earlier, params[:done] is a string, not a bool
[04:07:03] Jason: and so done: params[:done] isn't working
[04:07:44] Jason: i could use ActiveModel::Type::Boolean.new.cast
[04:08:34] Jason: yeah, that does work. hah. never thought this would make me think so much
[04:08:47] Jason: thanks much sevenseacat / matthewd
[04:08:51] sevenseacat: it will work just fine as where(done: params[:done])
[04:13:19] jhfisc: has joined #RubyOnRails
[04:14:11] kies: has joined #RubyOnRails
[04:25:43] jhfisc: has joined #RubyOnRails
[04:29:49] Jason: sevenseacat: it doesn't appear so
[04:30:23] Jason: sevenseacat: /todos?done=true
[04:30:29] Jason: Todo Load (0.3ms) SELECT "todos".* FROM "todos" WHERE "todos"."user_id" = ? AND "todos"."done" = ? [["user_id", 1], ["done", "true"]]
[04:30:34] Jason: nothing, []
[04:30:47] Jason: irb(main):017:0> Todo.where(done: "true")
[04:30:47] Jason: => #<ActiveRecord::Relation []>
[04:31:41] sevenseacat: seems to work here
[04:31:58] sevenseacat: do you have any todos that are done?
[04:32:27] jottr: has joined #RubyOnRails
[04:32:47] sevenseacat: https://gist.github.com/sevenseacat/921aeff54719653e7a914b6eff0569f4
[04:33:12] Jason: sevenseacat: i pulled up the console and tried it
[04:33:46] Jason: sevenseacat: https://gist.github.com/jasonharrison/1632f031f28ac6247280f1ece07c48d4
[04:34:39] sevenseacat: odd. what version of rails are you using, out of curiosity?
[04:35:35] jhfisc: has joined #RubyOnRails
[04:36:44] Jason: sevenseacat: rails 5.1.1
[04:38:24] Jason: sevenseacat: isn't that weird? hah
[04:38:40] sevenseacat: its not something i think i've seen before.
[04:38:54] Jason: sevenseacat: what version are you on?
[04:39:10] sevenseacat: 5.0.4, but I'm spinning up a new 5.1.1 app to look
[04:39:55] Jason: please do, that would be pretty funny if we found a bug
[04:40:09] Jason: i can't imagine that i'd be the first to notice that, though...
[04:41:16] sevenseacat: are you using sqlite?
[04:46:34] sevenseacat: I see that behaviour when using sqlite, but not when using psql
[04:46:40] sevenseacat: just tested both with Rails 5.1.2
[04:47:44] jhfisc: has joined #RubyOnRails
[04:47:45] patarr: has joined #RubyOnRails
[04:48:00] quazimodo: has joined #RubyOnRails
[05:12:09] jhfisc: has joined #RubyOnRails
[05:17:30] BigDiesel75: has joined #RubyOnRails
[05:18:12] jhfisc: has joined #RubyOnRails
[05:33:11] jottr: has joined #RubyOnRails
[05:35:07] jhfisc: has joined #RubyOnRails
[05:38:11] BigDiesel75: has joined #RubyOnRails
[05:41:18] brent__: has joined #RubyOnRails
[05:43:27] jhfisc: has joined #RubyOnRails
[05:43:59] krmela: has joined #RubyOnRails
[05:48:04] MrCrackPotBuilde: has joined #RubyOnRails
[05:49:40] jhfisc: has joined #RubyOnRails
[05:50:34] krmela: good morning everybody i am working on simple week view with indication , i am pass to partial template two variable @week which is date range first five days of week and day which is actual week and i wish in partial template use another style for actual day can anybody look on attached gist and told me what is wrong ? https://gist.github.com/netmoleCBA/c9fd3029a997fb50798774ec7200d080
[05:52:20] jhfisc: has joined #RubyOnRails
[05:53:42] dminuoso: krmela: What do you mean by "style" ?
[05:53:44] chandru_in: has joined #RubyOnRails
[05:54:02] dminuoso: krmela: Do you mean the output format?
[05:54:38] chandru_in: We have a large number of rails applications behind pgbouncer. What is the right way to disable Rails connection pooling entirely and let pgbouncer handle all the pooling?
[05:58:37] jhfisc: has joined #RubyOnRails
[05:59:57] krmela: dminuoso: output shall be simple list of li element where is by style highlighted active day
[06:00:18] Rodya_: has joined #RubyOnRails
[06:01:21] dminuoso: chandru_in: Are you on heroku?
[06:01:34] chandru_in: dminuoso: No
[06:01:42] dminuoso: krmela: I still do not understand what you mean by "style" in this context.
[06:03:15] krmela: dminuoso: ok let say today is Thursday so when is in partial rendred thursday i wish add that <li> class active
[06:03:41] krmela: dminuoso: just for another color rendering
[06:03:59] jhfisc: has joined #RubyOnRails
[06:05:09] krmela: dminuoso: i am pass partial week range and actual day just dont know how to make condition in partial to make another style assigment in partial den
[06:06:19] dminuoso: krmela: I cant be bothered to decipher your broken English.
[06:08:49] jhfisc: has joined #RubyOnRails
[06:08:49] dminuoso: chandru_in: Well all I know is that you have to explicitly turn off prepared statements in ActiveRecord. As for disabling the pooling, you could probably match the rails pool size to use as many external connections from your pgbouncer as you like
[06:09:12] dminuoso: Im not aware of any trivial approaches to disable the pooling entirely
[06:10:11] krmela: dminuoso: i send to partial hash of 5 dates and one date and i dont know how to compare in partial if two dates are same to render that date differently sorry for broken english
[06:10:28] chandru_in: In our prior experiments, we saw failures when we disabled prepared statements in rails. Matching pool size is not an option because we're talking about 100s of rails applications connecting to same DB server.
[06:12:43] jhfisc: has joined #RubyOnRails
[06:16:16] MrCrackPotBuilde: has joined #RubyOnRails
[06:20:33] dionysus69: has joined #RubyOnRails
[06:27:09] r3vDev: has joined #RubyOnRails
[06:28:46] conta: has joined #RubyOnRails
[06:30:25] jhfisc: has joined #RubyOnRails
[06:32:04] Jason: sevenseacat: 04:41:16 < sevenseacat> are you using sqlite?
[06:32:15] Jason: sevenseacat: apologies, i didn't see your message. indeed, sqlite
[06:33:57] jottr: has joined #RubyOnRails
[06:37:31] Jason: sevenseacat: surely it's activerecord's fault though, no?
[06:37:50] sevenseacat: that I don't know. i dont use sqlite.
[06:38:30] jhfisc: has joined #RubyOnRails
[06:39:03] Jason: sevenseacat: even in development, i wonder?
[06:39:12] sevenseacat: i dont use it at all.
[06:39:25] Jason: what do you use instead? pgsql?
[06:39:52] Jason: out of curiosity, what do you hold against sqlite?
[06:40:37] ascarter: has joined #RubyOnRails
[06:40:38] sevenseacat: it's not a production-scale database, and using different databases in development and production is a recipe for disaster
[06:40:57] sevenseacat: it doesnt support things like db-level foreign keys, and has weird bugs like this
[06:44:41] rgr: has joined #RubyOnRails
[06:45:08] chandru_in: What happens when prepared statements are disabled when using postgres? Will Rails just escape parameters and construct SQL string or will it use unnamed prepared statements with extended query protocol?
[06:48:13] patarr: has joined #RubyOnRails
[06:48:54] arBmind: has joined #RubyOnRails
[06:56:14] hnanon: has joined #RubyOnRails
[06:57:07] hnanon: I have the following in a view: class: ("active" if controller_name == "jobs")
[06:57:25] hnanon: How can I add another class, independent of the condition?
[06:57:48] hnanon: For example, something like: class: "dropdown-toggle" + ("active" if controller_name == "jobs")
[06:58:27] jottr: has joined #RubyOnRails
[07:00:34] umaaji: has joined #RubyOnRails
[07:02:34] Rodya_: has joined #RubyOnRails
[07:07:32] gwilkes: has joined #RubyOnRails
[07:12:14] jhfisc: has joined #RubyOnRails
[07:18:16] jhfisc: has joined #RubyOnRails
[07:33:42] jhfisc: has joined #RubyOnRails
[07:41:40] jhfisc: has joined #RubyOnRails
[07:48:09] ascarter: has joined #RubyOnRails
[07:59:13] dangerousdave: has joined #RubyOnRails
[07:59:58] mikecmpbll: has joined #RubyOnRails
[08:00:38] jottr: has joined #RubyOnRails
[08:03:04] Rodya_: has joined #RubyOnRails
[08:03:25] jhfisc: has joined #RubyOnRails
[08:06:35] MrCrackPotBuilde: has joined #RubyOnRails
[08:09:03] syndikate: has joined #RubyOnRails
[08:11:40] jhfisc: has joined #RubyOnRails
[08:15:35] adgtl: Folks here .. getting this error
[08:16:01] adgtl: Folks, I am getting this error - LoadError (Unable to autoload constant FirmwareUpdate, expected /Users/anil/Projects/abc/app/models/abc/firmware_update.rb to define it
[08:16:09] adgtl: but I have defined it there
[08:16:40] adgtl: It's defined as `class Abc::FirmwareUpdate` in firmware_update.rb
[08:16:41] universa1: adgtl: !code
[08:16:41] helpa: adgtl: We cannot help you with your problem if you don't show us your code. Please put it on http://gist.github.com and give us the URL so we can see it.
[08:17:18] universa1: you really have abc as module name?
[08:19:31] adgtl: universa1 https://gist.github.com/anildigital/83a29fb61df07f2582b3e32dec7ae445
[08:19:38] adgtl: universa1 there is actual code
[08:19:58] adgtl: you can see all folders under models are under `autoload_paths`
[08:20:07] universa1: adgtl: https://gist.github.com/anildigital/83a29fb61df07f2582b3e32dec7ae445#file-application-rb-L6-L10
[08:20:11] universa1: why are you doing that?
[08:20:36] Torrone: has joined #RubyOnRails
[08:20:45] adgtl: universa1 so that ruby files get autoloaded when requested
[08:20:54] universa1: adgtl: rails version?
[08:21:00] universa1: adgtl: 5.01
[08:21:11] universa1: it autoloads everything from app anyways...
[08:21:26] universa1: you don't need that stuff.
[08:21:28] adgtl: rails (5.0.1)
[08:21:49] adgtl: universa1 I have subfolders inside app/models
[08:21:51] universa1: the config/model_validators seems also a bit weird, soudns more like lib
[08:21:55] adgtl: universa1 isn't that necessary?
[08:21:59] universa1: adgtl: yes. even those it loads.
[08:22:26] adgtl: universa1 are you saying that I don't need to add those lines
[08:22:28] universa1: and your gist misses: /Users/anil/Projects/starling_guardian/app/models/starling/star.rb
[08:22:31] adgtl: let me try removing and testing
[08:22:36] universa1: adgtl: yes. line 10 i'm not sure
[08:22:45] dminuoso: chandru_in: Im not even remotely aware of the details, Id have to look into the source. You might want to hang around for someone with core knowledge to show up like matthewd
[08:22:46] universa1: 6 to 9 most surely not.
[08:23:01] chandru_in: Thank yo, dminuoso
[08:23:17] universa1: chandru_in: what happens if you try it? ;)
[08:23:49] chandru_in: I'll have to inspect Rails' communication with PG on the wire to figure that out. I can try some time later.
[08:24:47] ferr: has joined #RubyOnRails
[08:25:06] adgtl: universa1 after removing those lines I am getting this error https://gist.github.com/anildigital/76a7093206aa827764db342c791e4a5e
[08:25:31] marr: has joined #RubyOnRails
[08:25:44] universa1: adgtl: did you remove all lines? or just 6 to 9?
[08:26:02] adgtl: I tried both ... just 6-9 removed.. also tried 6-10
[08:26:08] adgtl: error is same in all the cases
[08:26:20] universa1: adgtl: okay, that is weird. so leave it in.
[08:27:34] adgtl: Do you know what could be reason behind 'LoadError (Unable to autoload constant FirmwareUpdate, expected /Users/anil/Projects/abc/app/models/abc/firmware_update.rb to define it' ?
[08:27:43] adgtl: I mean. I don't expect that error from Rails
[08:27:48] rrawlins: has joined #RubyOnRails
[08:28:12] universa1: adgtl: if you show the actual code, then maybe i could tell you.
[08:28:22] adgtl: universa1 screenhero?
[08:28:30] universa1: adgtl: no. just gist the actual files.
[08:28:35] adgtl: universa1 okay
[08:28:52] adgtl: what files do you want to see?
[08:28:59] adgtl: I had shared the application.rb
[08:29:03] adgtl: but anything else than that?
[08:29:07] universa1: and your gist misses: /Users/anil/Projects/starling_guardian/app/models/starling/star.rb
[08:30:15] Torrone: hello, I'm running a rails 3 application on an auto-scaling group on AWS, despite the CPU load being consistently low, sometimes requests time out with 500 or 504 error code but the server latency doesn't show values greater than 1.8s and it's mostly below 1 second, viewed from monitoring tools. What can I do to isolate the issue?
[08:30:58] universa1: Torrone: could also be slow requests to other external services... slow io
[08:31:12] universa1: not only high cpu usage.
[08:31:31] adgtl: universa1 https://gist.github.com/anildigital/a47a57b97e92c9f9b93781cc05a808df
[08:31:39] chandru_in: has left #RubyOnRails: ("Good Bye")
[08:32:01] Torrone: I think that all external services are hosted on AWS as well, so that part of the latency should be pretty low
[08:32:07] lxsameer: has joined #RubyOnRails
[08:32:47] rietta_: has joined #RubyOnRails
[08:33:07] universa1: well... "should" ... ;) and network latency is basically irrelevant... the problem
[08:34:37] universa1: my bet is on slow answers from external services (not due to actual network latency, just because they take as long as they take...)
[08:35:12] timdotrb: has joined #RubyOnRails
[08:35:13] universa1: or on autoscaling instance your request goes to an instance that has been shut down or is in the process of being shut down, or spinning up and not yet there.
[08:35:50] timdotrb: Evening, all
[08:36:00] adgtl: universa1 any clue?
[08:36:22] Torrone: universa1, there's a part that retrieves blog posts from a wordpress app, but it's also cached with memcached
[08:38:02] universa1: adgtl: well... your setup is a bit weird... and just checked an app where i used namespaced models, with ar though that most likely doesn't matter.
[08:38:18] universa1: adgtl: i don't need the autoload stuff, i've just the default rails settings.
[08:38:52] universa1: adgtl: i've the module defined in app/models/some_name.rb and the namespaced stuff in app/models/some_name/some_model.rb
[08:39:38] adgtl: hmm did not get you
[08:39:41] jhfisc: has joined #RubyOnRails
[08:39:47] adgtl: what do you have in appliacation.rb?
[08:39:51] adgtl: is it 5.0.1?
[08:40:27] timdotrb: How can I require user authentication for a particular route? I have the route /jobs defined for ActiveJob, but would like to restrict it to authenticated users. I know it’s easy enough to do with Devise, but I have rolled my own authentication
[08:40:48] mikecmpbll: what controller does that route route to?
[08:40:53] universa1: adgtl: https://gist.github.com/universal/1111882ce9a2e1c05a2761f322525bf4
[08:41:17] dionysus69: some weird bootstrap behavior in both sass bootstrap gem 3.3.6 and bootstrap 4 alpha gem https://gist.github.com/5116f28b470bed915e104f9a531baed2 whole tbody is being rendered under first column in bootstrap 4 and as for bootsrap 3, there is a 1 column shift, so thead and tbody are misaligned by 1 column
[08:41:19] universa1: adgtl: nothing concerning paths... i haven't touched that since rails 2.3
[08:41:33] adgtl: universa1 what's there in application.rb then?
[08:42:01] krmela: good day there , i am use lastest rails and web i see all used variables just dont know what happends on page are just two levels of partials any idea http://pasteall.org/pic/show.php?id=116806
[08:42:05] universa1: adgtl: reload the gist
[08:43:16] timdotrb: mikecmpbll: I’m not sure. It’s part of Resque. The route itself is: mount Resque::Server, at: '/jobs'
[08:43:45] adgtl: universa1 okay
[08:43:57] mikecmpbll: krmela : good day. looks like you are outputting an array of Food active record objects. looks like you might have a <%= where you want a <%
[08:44:48] universa1: dionysus69: even though that is not a rails question... remove the row class from tr.
[08:45:30] dionysus69: universa1: omfg who would have though that could be an issue :D thanks so much I spent half an hour on this :D :D
[08:45:44] jhfisc: has joined #RubyOnRails
[08:45:53] universa1: dionysus69: o0... inspect with chrome?
[08:45:57] mikecmpbll: timdotrb : https://github.com/thoughtbot/clearance#access-control might help
[08:46:25] mikecmpbll: timdotrb : nvm, i got mixed up there
[08:46:49] mikecmpbll: but perhaps look how they create the route constraints, it might be applicable to your custom auth
[08:46:50] dionysus69: universa1: I noticed nothing wrong (firefox dude here). I disabled all styling still same, it was corrected only when I removed bootstrap from app scss.
[08:46:52] universa1: timdotrb: check that the user is logged in a before_action filter?
[08:47:05] timdotrb: universa1: in the app controller?
[08:47:09] mikecmpbll: universa1 : i think the controllers are from an engine
[08:47:20] timdotrb: Yea, I think so, too
[08:47:21] universa1: timdotrb: no in the controller that you want checked.
[08:47:23] krmela: mikecmpbll: https://gist.github.com/netmoleCBA/57cafbd3c8273ee0f53904d221290eea i dont see that i have it anywhere
[08:47:30] timdotrb: universa1: not an option
[08:47:45] universa1: timdotrb: ?
[08:47:57] mikecmpbll: krmela : https://gist.github.com/netmoleCBA/57cafbd3c8273ee0f53904d221290eea#file-_dodavatel-html-erb-L10
[08:48:10] timdotrb: universa1: It’s built into the resque gem. https://github.com/resque/resque/blob/master/lib/resque/server.rb
[08:48:11] mikecmpbll: krmela : `each` returns the receiver, so it returns `supplier.food`, which is then outputted.
[08:48:29] universa1: timdotrb: never read resque before.
[08:48:31] mikecmpbll: timdotrb : here y'are: https://github.com/mperham/sidekiq/wiki/Monitoring#custom-external-authentication
[08:49:01] mikecmpbll: something like that anyway :/
[08:49:05] dangerousdave: has joined #RubyOnRails
[08:49:12] patarr: has joined #RubyOnRails
[08:49:34] timdotrb: mikecmpbll: Sweet, I’ll give that a try. Thanks :)
[08:49:54] timdotrb: I attempted implementing something similar to Devise, but they use warden -_- https://github.com/plataformatec/devise/blob/master/lib/devise/rails/routes.rb#L288-L292
[08:50:13] universa1: timdotrb: https://github.com/resque/resque-web#security
[08:50:41] timdotrb: universa1: perfect
[08:50:47] krmela: mikecmpbll: do you give me hint how to do remake it ?
[08:51:11] timdotrb: Although.. That also uses warden
[08:51:38] universa1: krmela: https://gist.github.com/netmoleCBA/57cafbd3c8273ee0f53904d221290eea#file-index-html-erb-L17
[08:51:46] universa1: krmela: https://gist.github.com/netmoleCBA/57cafbd3c8273ee0f53904d221290eea#file-index-html-erb-L22
[08:53:28] krmela: Ty mates i was blind ty very much
[08:53:38] universa1: timdotrb: you can also open up the resque-web classes and add your stuff there.
[08:53:57] mikecmpbll: yeah, that's probably easiest tbf
[08:54:06] universa1: timdotrb: https://github.com/resque/resque-web/blob/master/app/controllers/resque_web/application_controller.rb -- this one
[08:55:14] timdotrb: universa1: Hmm.. I might do that. I’m going to try adding my user object to a request.env variable first
[08:55:42] universa1: timdotrb: my guess is you need to have an actual middleware then, like warden ;)
[08:55:52] timdotrb: universa1: touché
[08:56:02] universa1: because that needs to happen before routing, and that is before hitting any controllers ;)
[08:58:54] srinidhi: has joined #RubyOnRails
[08:59:16] xibalba: has joined #RubyOnRails
[09:01:25] jottr: has joined #RubyOnRails
[09:03:51] Rodya_: has joined #RubyOnRails
[09:04:40] xibalba: has joined #RubyOnRails
[09:10:48] arBmind: has joined #RubyOnRails
[09:11:25] srinidhi: has joined #RubyOnRails
[09:19:10] jhfisc: has joined #RubyOnRails
[09:22:23] dminuoso: What's wrong with using warden?
[09:29:37] jhfisc: has joined #RubyOnRails
[09:30:06] adgtl: universa1 hey.. I needed to something like this to fix that issue https://gist.github.com/anildigital/cb2f1d418fe0622db687b0a17b37ea37
[09:30:07] ionte: has joined #RubyOnRails
[09:30:12] adgtl: that doesn't look legit
[09:30:20] adgtl: but does it tell anything about real problem?
[09:30:53] adgtl: I need to have both class Star and class Starling::Star in star.rb
[09:30:58] adgtl: otherwise it throws that error
[09:31:07] adgtl: bit wrong
[09:31:42] universa1: adgtl: my guess is because you have mangled with the autoload paths
[09:31:46] universa1: that it is broken
[09:32:12] ionte: hi. in a bit of a trouble. an error was found in production and it's related to strong parameters: i have incoming parameters like this: :variants => { "2391" => { "price" => 100, "name" => "foo" }, "3182" => { "price" => 200, "name" => "bar" } }
[09:32:15] universa1: adgtl: because by default app/models is only on the eager_load paths and not on the autoload path
[09:32:21] AzaToth: has joined #RubyOnRails
[09:32:35] adgtl: universa1 hmm
[09:32:42] ionte: so it attempts to update multiple selected variants at once. how would i write "strong parameters" for that?
[09:32:58] universa1: ionte: have you checked the strong parameters docs and the guide?
[09:34:19] universa1: ionte: that looks strongly like params for accepts_nested_attributes_for
[09:34:49] universa1: ionte: params.require(:blub).permit(variants: [:price, :name]) iirc
[09:35:17] jhfisc: has joined #RubyOnRails
[09:36:26] ionte: universa1 hm, but i think :blub is :variants in my example, and i'm not sure what to put where you use :variants
[09:36:49] adgtl: universa1 I wonder why my app look for autoload constant Star, and autoload constant Starling::Star in same file star.rb
[09:37:00] adgtl: file usually would have only one constant there
[09:37:05] ionte: perhaps i don't need 'require'....
[09:37:16] adgtl: what makes it to go for 2 constants Star and Starling::Star
[09:37:40] universa1: adgtl: my guess is your subdirectory is on the autoload path
[09:37:44] adgtl: who told Rails to search for both constants in same file
[09:37:56] universa1: adgtl: so any file in there is expected to not be in a module.
[09:38:17] dminuoso: adgtl: Please give us a specific testcase.
[09:39:11] adgtl: universa1 how to find out if 'your subdirectory is on the autoload path' is true
[09:39:26] universa1: adgtl: Rails.application.config.autoload_paths
[09:40:31] adgtl: dminuoso https://gist.github.com/anildigital/83a29fb61df07f2582b3e32dec7ae445
[09:40:57] dminuoso: I wish people would stop using monogodb..
[09:41:06] universa1: ionte: a = your_hash; ap = ActionConParams.new a; ap.permit(variants: [:price, :name])
[09:41:08] adgtl: dminuoso it forces me to have both class Star and class Starling::Star in same file
[09:41:58] dminuoso: adgtl: Why?
[09:42:25] adgtl: dminuoso don't know why.. otherwise it throws that constant not found in file error
[09:42:36] adgtl: dminuoso trying to find solution for this issue
[09:42:58] dminuoso: adgtl: I still dont see any relevant code.
[09:43:01] adgtl: Not sure.. how Rails gets 2 constants Star and Starling::Star to look in the same file star.rb
[09:43:03] universa1: dminuoso: my guess is he has weird autoload paths, so app/models/starling is on the autoload path
[09:43:10] adgtl: which is there in models/starling/star.rb
[09:43:25] adgtl: dminuoso what do you want to see.. I can share
[09:43:30] universa1: dminuoso: which in turn requires class Star; end to be defined there, and not class Starling::Star; end
[09:43:32] jhfisc: has joined #RubyOnRails
[09:48:46] adgtl: dminuoso ?
[09:49:03] jhfisc: has joined #RubyOnRails
[09:52:41] ionte: universa1: thanks! as a matter of fact, it was enough to remove the "require". here's what i do: "params.permit(variants: [:price, :name])". it works perfectly, and i hope there's no subtle security problem with it.
[09:52:56] ionte: this is more or less what you suggested as well...
[09:53:41] jhfisc: has joined #RubyOnRails
[09:56:24] ascarter: has joined #RubyOnRails
[10:01:55] czerasz: has joined #RubyOnRails
[10:02:08] jottr: has joined #RubyOnRails
[10:02:31] jhfisc: has joined #RubyOnRails
[10:04:49] Rodya_: has joined #RubyOnRails
[10:08:52] jhfisc: has joined #RubyOnRails
[10:16:03] dminuoso: adgtl | I need to have both class Star and class Starling::Star in star.rb
[10:16:22] dminuoso: I still have my doubts about that.
[10:16:24] adgtl: I mean to advoid the issue
[10:16:50] adgtl: issue is that I am getting LoadError (Unable to autoload constant Star, expected /Users/anil/Projects/starling_guardian/app/models/starling/star.rb to define it):
[10:16:52] adgtl: otherwise
[10:17:14] dminuoso: adgtl: The issue is very simple.
[10:17:25] adgtl: dminuoso hmm
[10:17:27] dminuoso: adgtl: You ignore how the autoloading algorithm works with respect to nesting.
[10:17:40] jhfisc: has joined #RubyOnRails
[10:17:57] adgtl: dminuoso sorry....... how can I ignore that? rails is throwing error
[10:19:58] dminuoso: adgtl: Please show us how you try to use "Star" to begin with.
[10:20:33] adgtl: Starling::Star
[10:20:39] dminuoso: Show me the code.
[10:20:41] adgtl: from many places
[10:20:41] dminuoso: The entire file.
[10:20:48] dminuoso: adgtl: The place that causes the issue.
[10:21:00] dminuoso: adgtl: I dont have a complete picture as it stands right now.
[10:21:09] adgtl: dminuoso https://gist.github.com/40124723343af39d3893d0964d630869
[10:21:12] dminuoso: adgtl: I need to look at the entirety to know how the autoloading mechanism is stumbling.
[10:21:33] dminuoso: adgtl: You do not reference the constant "Star" in there.
[10:21:35] adgtl: dminuoso error comes while loading the file
[10:21:41] dminuoso: No it does not.
[10:21:53] dminuoso: adgtl: The error happens because something else is referencing "Star"
[10:21:58] timdotrb: has joined #RubyOnRails
[10:22:02] adgtl: dminuoso hmm it's residing in app/models/starling/star.rb
[10:22:03] dminuoso: And that "something else" is what I want to see.
[10:22:05] dminuoso: I dont care.
[10:22:11] adgtl: and thats why Starling::Star
[10:22:47] adgtl: dminuoso I searched project and I could not find that something else referencing Star
[10:22:53] timdotrb: has joined #RubyOnRails
[10:22:54] adgtl: I also want to know that
[10:22:59] czerasz: has joined #RubyOnRails
[10:23:02] dminuoso: 12:16:50 adgtl | issue is that I am getting LoadError (Unable to autoload constant Star, expected /Users/anil/Projects/starling_guardian/app/models/starling/star.rb to define it): │ cardoni
[10:23:10] dminuoso: adgtl: It clearly _is_ trying to autload the constant Star.
[10:23:12] dminuoso: Give me the stack trace
[10:23:16] dminuoso: of that error.
[10:23:38] Fernando-Basso: has joined #RubyOnRails
[10:24:31] adgtl: dminuoso sure
[10:25:12] arup_r: has joined #RubyOnRails
[10:25:28] adgtl: dminuoso here it is https://gist.github.com/254aa66dfea35c4ee80d733f43462eb1
[10:25:39] dminuoso: adgtl: stop giving me any more gists.
[10:25:42] dminuoso: Condence them into one.
[10:26:22] adgtl: for now use the last gist I shared.. I will udpate it
[10:27:11] adgtl: dminuoso updated gist
[10:27:40] jhfisc: has joined #RubyOnRails
[10:27:59] dminuoso: adgtl: add the controller that contains the action for that
[10:30:26] adgtl: dminuoso I have added controllers to gist
[10:32:04] adgtl: dminuoso also added stars_controller.rb just now
[10:33:46] Moeh: has joined #RubyOnRails
[10:34:01] dminuoso: adgtl: The thing that trips me up right now is the stack trace.
[10:34:16] dminuoso: Trying to figure out what part is trying to autoload "Star" to begin with.
[10:35:39] dminuoso: adgtl: Interesting, yeah it actually happens before your controller is even met.
[10:35:46] dminuoso: Its triggered by ActionController::Metal itself
[10:36:01] dminuoso: adgtl: It's related to the naming of your controller somehow.
[10:36:49] dminuoso: adgtl: include your Api::V1::Me::ApplicationController
[10:36:51] adgtl: naming of controller or model?
[10:36:55] dminuoso: adgtl: do you have wrap_parameters anywhere?
[10:36:59] dminuoso: adgtl: The controller itself.
[10:37:41] dminuoso: adgtl: but yeah, include the base controller I asked for.
[10:37:41] rainy_mood2002: has joined #RubyOnRails
[10:38:08] rainy_mood2002: Hello everyone, how do i test API destroy actions?
[10:38:18] adgtl: dminuoso just updated gist with wrap_parameters.rb
[10:38:34] dminuoso: adgtl: That's the cause somehow. I gotta run, lunch.
[10:38:42] adgtl: dminuoso include the base controller?
[10:38:48] dminuoso: adgtl: Not necessary anymore.
[10:39:22] dminuoso: adgtl: wrap_parameters causes a mode where Rails will try to guess a model name based on `Api::V1::Me::StarsController` -> dont have the time to analyze in depth, but that "heuristic" search causes Ruby to look for a "Star" constant.
[10:39:25] adgtl: dminuoso did not get you
[10:39:27] dminuoso: And that's what makes it stumble.
[10:39:38] adgtl: dminuoso hmm
[10:39:43] adgtl: dminuoso what to remove
[10:39:50] dminuoso: I dont know, would have to look further.
[10:39:56] dminuoso: Someone else can help you. Gotta go bye/
[10:41:33] adgtl: Diabolik removing wrap_parameters.rb seemed to have helped.. dminuoso thanks
[10:41:45] adgtl: dminuoso ^^
[10:50:11] patarr: has joined #RubyOnRails
[11:00:29] adgtl: $ gem install rails
[11:00:29] adgtl: Successfully installed rails-5.1.2
[11:00:30] adgtl: 1 gem installed
[11:00:37] adgtl: that command installs only 1 gem
[11:00:41] adgtl: what about other gems?
[11:02:52] jottr: has joined #RubyOnRails
[11:05:24] Rodya_: has joined #RubyOnRails
[11:12:18] gwilkes: has joined #RubyOnRails
[11:13:05] rrawlins: Hey folks, quick Q: Does the process sit and wait for a pessimistic lock to become available? Or does it raise an error right away? Couldn't find specific details in the docs about it.
[11:13:36] universa1: rrawlins: more context?!
[11:13:52] universa1: rrawlins: try?
[11:15:20] rrawlins: universa1: I haven't tried mocking it up, thought I'd ask before going to the bother. Context is, say I wrap some code in a pessimistic lock, using with_lock() or similar, and another process tries to run the same locked code, will it wait until the first process finishes and then run, or will the second process fail the moment it tries to run something which is already locked?
[11:15:56] universa1: rrawlins: "mocking" it up should be done quickly ;) can't remember either.
[11:17:42] rrawlins: universa1: no problem, just thought I'd put it out there. I'll create an example, see how it behaves. Appreciate the input.
[11:18:50] delgiudices: has joined #RubyOnRails
[11:27:20] Moeh: has joined #RubyOnRails
[11:28:07] adgtl: Getting an exception for a trivial piece of code https://gist.github.com/1c3b3bc1138e0085e369539f3218a026
[11:28:15] adgtl: Anyone interested to take a look there?
[11:28:22] dionysus69: I want to generate timestamp manually, is this the right way to do? Time.now.getutc I want to insert it into the update_at column, note it has to be without timezone
[11:28:39] universa1: adgtl: rake routes
[11:29:02] universa1: adgtl: and resources :stars do; collection do; get :hello; end; end
[11:29:20] adgtl: universa1 updated gist
[11:29:39] universa1: adgtl: https://gist.github.com/anildigital/1c3b3bc1138e0085e369539f3218a026#file-rake_routes-txt-L2
[11:30:53] dionysus69: just checked Time.now.getutc this is equivalent to Time.zone.now, does it make sense?
[11:31:18] jarr0dsz: has joined #RubyOnRails
[11:32:05] adgtl: universa1 thanks
[11:32:32] quazimodo: has joined #RubyOnRails
[11:35:25] roshanavand: has joined #RubyOnRails
[11:41:55] jarr0dsz: hello everyone i have modified my database connectors ( multitennant) so there is no default database connection that is normally initiated from config.yml
[11:42:17] jarr0dsz: so i get Mysql2::Error: No database selected: SHOW FULL FIELDS FROM `organisations` when my session is timedout and the db connection is no longer active
[11:42:41] jarr0dsz: is here a nice way to implement a resque on no database connection? so i can redirect to the login page instead of that my application throws this exception?
[11:43:06] jarr0dsz: i tried to it in a before_filter in my application_controller but this fails since certain calls to the db seems to be made upfront
[11:43:47] jarr0dsz: so ideal would be a way to rescue AR with an exception instead, could not find anything on this
[11:44:19] jarr0dsz: it seems activerecord (5.1.2) lib/active_record/model_schema.rb:471:in `load_schema!' it goes wrong here
[11:47:10] patarr: has joined #RubyOnRails
[11:53:46] Arkentias: has joined #RubyOnRails
[11:54:55] Arkentias: has joined #RubyOnRails
[11:59:18] jarr0dsz: has joined #RubyOnRails
[11:59:35] jarr0dsz: would there be a way to rescue from AR if it fails to connect to db?
[11:59:47] jarr0dsz: i would need to monkey patch the layer where it starts looking for the db
[12:00:52] jarr0dsz: with this stracktrace https://gist.github.com/anonymous/efc9393dc2584abd72545320c41f1c7d
[12:01:14] ascarter: has joined #RubyOnRails
[12:03:37] jottr: has joined #RubyOnRails
[12:06:07] Rodya_: has joined #RubyOnRails
[12:07:02] czerasz: has joined #RubyOnRails
[12:08:26] dionysus70: has joined #RubyOnRails
[12:24:14] rorNoob_: has joined #RubyOnRails
[12:28:16] jarr0dsz: I pointed it down to rescue_from ActiveRecord::StatementInvalid do |e| but is there a 'connection' method not in this class
[12:28:31] jarr0dsz: so i can rescue on the class method that tries to initiate the db anyone knows please?
[12:29:39] rorNoob_: Hey. I've been trying to expand the Guide to Rails blog application to include "Article Tags". I've created a Tag Model which belongs to Article - I am now trying to create a new route for articles/findByTag/<myTag> which would should all articles with a given tag.
[12:30:42] rorNoob_: in the articles controller I've created a new function "def showByTag(tag)" but it wont register as a route
[12:31:29] universa1: rorNoob_: routes are defined in the config/routes.rb file
[12:31:48] universa1: rorNoob_: for an explanation on how to define routes, add custom actions, etc... see the routing guide:
[12:31:50] rorNoob_: Also, I am unsure on how to filter Article.all or use Article.find without the params - as tag is not a parameter in the article (db sqlite3 schema)
[12:31:53] universa1: rorNoob_: !routing
[12:31:54] helpa: rorNoob_: http://guides.rubyonrails.org/routing.html - Rails Routing From the Outside In - Rails Guide - by Mike Gunderloy
[12:32:21] universa1: rorNoob_: think about it from a different angle: first find the tag for the supplied param
[12:32:43] universa1: rorNoob_: and then you should have an association on Tag, which references all articles for that tag
[12:33:13] universa1: rorNoob_: so it boils down to: tag = Tag.where(name: params[:tag]).first; @articles = tag.articles
[12:33:25] universa1: rorNoob_: also helpful is probably the associations guide:
[12:33:28] universa1: !associations
[12:33:28] helpa: http://guides.rubyonrails.org/association_basics.html - Active Record Association Basics by Mike Gunderloy
[12:33:44] rorNoob_: alright. will look into it
[12:35:27] universa1: rorNoob_: if you're stuck along the way, ask again... there is most likely someone around which can point you in the right direction
[12:35:53] jarr0dsz: argh, the problem is my database not found is even called before he applicationcontroller
[12:47:06] quirkycoders: has joined #RubyOnRails
[12:52:19] chimkan: has joined #RubyOnRails
[12:58:43] Rodya_: has joined #RubyOnRails
[13:04:22] berserk_ren: has joined #RubyOnRails
[13:04:26] jottr: has joined #RubyOnRails
[13:13:52] cseder: has joined #RubyOnRails
[13:17:04] rfoust: has joined #RubyOnRails
[13:19:00] cam27: has joined #RubyOnRails
[13:23:42] quirkycoders: has joined #RubyOnRails
[13:25:34] rorNoob_: universal: thanks for the help! I'm starting to figure things out... I've now encountered a new problem though. Each time I add a tag to an article, it gets a new id.. is there a simple solution so it wont create a new tag, but search existing tags already for the same name
[13:25:34] jphase: has joined #RubyOnRails
[13:25:45] rorNoob_: Something like @article.tags.create_if_not_exists(tag_params)
[13:26:39] rorNoob_: or should I just do Tags.all and search for the ones with the same name values as in tag_params
[13:26:49] dminuoso: Given the :cookie_store, where does rails hold the session keys?
[13:27:04] jhfisc: has joined #RubyOnRails
[13:28:22] rorNoob_: as in @tag = Tags.all.find(params[:tag])
[13:30:26] jhfisc: has joined #RubyOnRails
[13:33:51] rorNoob_: well, find doesnt work because its find by id
[13:34:11] rorNoob_: what about .where("tag=" params[:tag])
[13:35:25] tbuehlmann: rorNoob_: as you want to reuse tags, you'll need a join model
[13:35:41] tbuehlmann: if you don't have a join model, you'll create new tags all over again
[13:35:47] jhfisc: has joined #RubyOnRails
[13:36:30] tbuehlmann: you could have a join model named "Tagging", with Article.has_many :taggings, Article.has_many :tags, through: :taggings, Tag.has_many :taggings, Tagging.belongs_to :tag and Tagging.belongs_to :article
[13:38:38] tetsu: has joined #RubyOnRails
[13:38:40] jhfisc: has joined #RubyOnRails
[13:39:27] tetsu: Hi, new here and haven't used irc in quite a long time tbh
[13:39:47] DoubleMalt: has joined #RubyOnRails
[13:41:12] tetsu: Wanted to check if anyone had any knowledge of something I am trying to resolve
[13:41:59] tetsu: I want to authenticate access to sidekiq web console, but I am not using rails to provide any views
[13:42:33] jhfisc: has joined #RubyOnRails
[13:42:37] tetsu: I am using react against a rails api authenticated via jwt
[13:43:21] rorNoob_: tbuehlmann: How would my schema look like? something like this: table tag with id, text. --- table tagging with id, article_id, tag_id --- table article with id, tagging_id, etc...?
[13:43:29] tetsu: Anyone have any knowledge of suggestions for authenticating access to web console for this kind of setup?
[13:43:58] tetsu: Sorry * sidekiq web console
[13:44:09] tbuehlmann: rorNoob_: the articles table doesn't need a tagging_id
[13:44:28] tbuehlmann: it's only the tagging that knows about the connection between a single tag and a single article
[13:44:51] rorNoob_: yeah, but i want a single article to be linked to multiple tags
[13:45:04] rorNoob_: or do I have to go over the tagging table and join the results myself
[13:45:43] dionysus69: has joined #RubyOnRails
[13:46:02] tbuehlmann: when an article has 3 tags, that'll be 3 rows in the taggings table
[13:46:37] tbuehlmann: when you want to get all the tags for a given article, you just call article.tags
[13:48:09] jhfisc: has joined #RubyOnRails
[13:49:52] Rodya_: has joined #RubyOnRails
[13:50:09] rorNoob_: yeah, but back to my original question: i want a showByTag endpoint to show all articles with a given tag - do I need to go over all of the Tagging table and their connected tables filter all of the articles?
[13:50:33] rorNoob_: in order to* filter all of the articles
[13:51:24] tbuehlmann: you could add another association in your Tag model: Tag.has_many :articles, through: :taggings
[13:51:34] tbuehlmann: that way you can find your tag and call tag.articles on it
[13:51:58] rorNoob_: Tagging.all.where('tag_id=':tag_id) would give me all of the article_id's with that tag_id - right?
[13:52:14] shotbug: has joined #RubyOnRails
[13:53:40] jhfisc: has joined #RubyOnRails
[13:55:13] roshanavand: has joined #RubyOnRails
[13:56:04] cabuloso: has joined #RubyOnRails
[13:56:42] tbuehlmann: rorNoob_: does this answer your question?
[13:57:31] patarr: has joined #RubyOnRails
[13:58:52] rorNoob_: tbuehlmann: i'll play with it more and see if i can figure it out. thanks!
[14:02:49] jhfisc: has joined #RubyOnRails
[14:03:29] ascarter: has joined #RubyOnRails
[14:04:10] delgiudices: has joined #RubyOnRails
[14:05:31] jottr: has joined #RubyOnRails
[14:06:38] rorNoob_: okay, tbuehlmann, so far I've used the partial form for tags to be rendered in an article withe the following: form_for([@article, @article.tags.build]) do |f|
[14:07:01] rorNoob_: So now, if I understand correctly, I need to use a partial form for tagging instead of tags.
[14:07:53] rorNoob_: and it should be form_for([@tag, @tag.tags.build])
[14:08:50] chouhoulis: has joined #RubyOnRails
[14:11:37] tbuehlmann: you probably want to use Article.accepts_nested_attributes_for :taggings so you can have taggings in your article when saving the form
[14:12:15] tbuehlmann: have to leave now, being back in like 2 hours
[14:16:07] jhfisc: has joined #RubyOnRails
[14:23:07] timharding: has joined #RubyOnRails
[14:24:46] ResidentBiscuit: has joined #RubyOnRails
[14:26:06] timharding: Hi, the guides for 4.2 seem to be unavailable and http://guides.rubyonrails.org/v4.2/ redirects to http://edgeguides.rubyonrails.org. Who owns that? How can I report it?
[14:27:58] jhfisc: has joined #RubyOnRails
[14:44:16] dminuoso: timharding: You can file an issue at github
[14:44:27] dminuoso: timharding: Or perhaps matthewd is around to notice
[14:44:53] dminuoso: timharding:
[14:44:56] dminuoso: https://github.com/rails/rails/issues
[14:48:12] jottr: has joined #RubyOnRails
[14:48:14] beingjohnm: has joined #RubyOnRails
[14:59:19] jhfisc: has joined #RubyOnRails
[15:05:49] alfie: has joined #RubyOnRails
[15:08:08] cseder: has joined #RubyOnRails
[15:08:10] matthewd: Ah, the 4.2.9 release must've failed to generate
[15:08:22] matthewd: timharding: http://guides.rubyonrails.org/v4.2.8/ should work for now
[15:08:52] jhfisc: has joined #RubyOnRails
[15:10:47] quazimodo: has joined #RubyOnRails
[15:14:32] dminuoso: matthewd: Would github have been the correct place to recommend?
[15:14:47] dminuoso: Was looking for some kind of "contact" or "site maintainer" links, but couldn't find any.
[15:15:11] matthewd: Yes, thanks (but I've passed along a suitable poke)
[15:19:13] delgiudices: has joined #RubyOnRails
[15:23:01] Rodya_: has joined #RubyOnRails
[15:26:48] patarr: has joined #RubyOnRails
[15:28:50] centrx: has joined #RubyOnRails
[15:35:40] brent__: has joined #RubyOnRails
[15:38:22] Borgelman: has joined #RubyOnRails
[15:39:09] jhfisc: has joined #RubyOnRails
[15:43:20] xco: has joined #RubyOnRails
[15:43:56] jhfisc: has joined #RubyOnRails
[15:44:22] SteenJobs: has joined #RubyOnRails
[15:44:44] xco: hi. this line is always returning “false” https://gist.github.com/siaw23/3332054d8db50d1e188cbcd8d5cbb2ac#file-controller-rb-L13 is there a better way to rewrite the “create” method? worked on rails 4.0 not when i upgraded to 5.0. i feel something about params.permit changed in Rails 5.0. not so sure how to fix this one. help?
[15:44:55] SteenJobs: has joined #RubyOnRails
[15:47:03] chimkan: has joined #RubyOnRails
[15:50:46] centrx: xco: Normally you do if @x.save
[15:51:28] centrx: xco: What is TrainingCollectionGenerator, why is its method #valid? returning false?
[15:51:54] centrx: I guess it's just a regular model, but normally use save
[15:52:16] xco: centrx: what if i don’t want to save?
[15:52:31] jhfisc: has joined #RubyOnRails
[15:52:35] xco: #save will still fail because of validation checks
[15:52:44] centrx: xco: Then the question becomes what is schedule! and what is valid?
[15:52:44] NoGodDamnIdea: has joined #RubyOnRails
[15:52:54] centrx: xco: Sure, but that means the record is not valid?
[15:53:06] centrx: xco: So maybe you don't want to check if valid?
[15:53:12] xco: the record expects :training_collection_generator
[15:53:17] xco: from the param method
[15:53:21] tercenya: has joined #RubyOnRails
[15:53:24] xco: to be valid
[15:53:56] xco: so i need to somehow create a new TrainingCollectionGenerator with the params there PLUS the params from the private method
[15:53:59] xco: for it to be valid
[15:54:54] troys: has joined #RubyOnRails
[15:59:38] guardianx: has joined #RubyOnRails
[16:00:39] DaveTaboola: has joined #RubyOnRails
[16:02:20] quazimodo: has joined #RubyOnRails
[16:05:56] timharding: matthewd: thanks
[16:06:03] timharding: dminuoso: thanks
[16:07:50] ascarter: has joined #RubyOnRails
[16:07:57] conta: has joined #RubyOnRails
[16:12:30] jhfisc: has joined #RubyOnRails
[16:15:40] jhfisc: has joined #RubyOnRails
[16:21:44] jhfisc: has joined #RubyOnRails
[16:22:30] marr: has joined #RubyOnRails
[16:24:07] [Butch]: has joined #RubyOnRails
[16:32:22] jhfisc: has joined #RubyOnRails
[16:34:52] HoierM: has joined #RubyOnRails
[16:37:08] preisform: has joined #RubyOnRails
[16:37:08] delgiudices: has joined #RubyOnRails
[16:39:07] Technodrome: has joined #RubyOnRails
[16:49:13] gdonald: has left #RubyOnRails: ("Leaving")
[17:00:25] sloggerkhan: has joined #RubyOnRails
[17:16:18] kies: has joined #RubyOnRails
[17:17:21] ericnw: has joined #RubyOnRails
[17:18:46] timdotrb: has joined #RubyOnRails
[17:20:07] jhfisc: has joined #RubyOnRails
[17:21:08] alexandreangelim: has joined #RubyOnRails
[17:30:35] jhfisc: has joined #RubyOnRails
[17:31:31] EPic_Null: has joined #RubyOnRails
[17:38:00] xco: has ##column_names been remove from Rails 5.0?
[17:38:28] EPic_Null: Is there something special you have to do to get css to load in Rails? I've tried a couple of different things ( putting "config.sass.preferred_syntax = :scss" in enviornments/development and putting all the rules in a seperate file in the assets folder and putting "<%= stylesheet_link_tag "all" %>" in my index.html.erb ), and the browser seems to be recieving them if I search around in...
[17:38:30] EPic_Null: ...inspect-element, but they're not being used. Full program: https://github.com/engineer-pearl/Outside_on_rails
[17:40:19] netzfisch: has joined #RubyOnRails
[17:42:32] Ferdroid: has left #RubyOnRails: ()
[17:43:38] chimkan: has joined #RubyOnRails
[17:46:20] jhfisc: has joined #RubyOnRails
[17:49:42] jhfisc: has joined #RubyOnRails
[17:53:06] ericnw: has left #RubyOnRails: ()
[17:54:16] lessless: has joined #RubyOnRails
[17:56:53] newton: EPic_Null: your css is invalid
[17:57:46] newton: EPic_Null: "headr" means the element "headr" vs doing ".headr" which is a proper css class
[17:59:19] EPic_Null: Oh! Thanks. *facedesk*
[17:59:29] jhfisc: has joined #RubyOnRails
[18:00:26] chimkan: has joined #RubyOnRails
[18:03:00] jottr: has joined #RubyOnRails
[18:10:34] ascarter: has joined #RubyOnRails
[18:13:44] jhfisc: has joined #RubyOnRails
[18:16:22] dviola: has joined #RubyOnRails
[18:16:54] dionysus69: when I set custom primary key in model. Do I need to change anything in migration? like adding db indexing to the new pk?
[18:23:47] jhfisc: has joined #RubyOnRails
[18:29:04] jhfisc: has joined #RubyOnRails
[18:36:20] pLaTo0n: has joined #RubyOnRails
[18:38:38] delgiudices: has joined #RubyOnRails
[18:38:38] chimkan: has joined #RubyOnRails
[18:42:15] Malgorath: has joined #RubyOnRails
[18:43:54] Malgorath: Hi, I was wondering if there is a way inside of a view to search the object like parent.child.id so that I could do something like <%= child.text = parent.child.id.find(2) %>
[18:51:41] chimkan: has joined #RubyOnRails
[18:55:29] cseder: has joined #RubyOnRails
[18:57:34] tbuehlmann: Malgorath: you could, but I don't understand that last part
[18:57:43] tbuehlmann: but I would prefer to define the variables in the controller
[18:57:51] Malgorath: <% unless process_step.dependency.nil? %> <strong title="<%= process_step.find_by(["id = ?", process_step.dependency]).title %>">REQ</strong><% end %>
[18:58:05] Malgorath: tbuehlmann, like that(course that method does not work since there is no find_by
[18:58:14] gusrub: has joined #RubyOnRails
[19:00:06] timdotrb: Afternoon, all
[19:00:09] jhfisc: has joined #RubyOnRails
[19:03:32] tbuehlmann: Malgorath: mh, I don't understand
[19:03:46] jottr: has joined #RubyOnRails
[19:05:41] Maletor: has joined #RubyOnRails
[19:06:01] timdotrb: I’m trying to find records on one of my models where the status is active and there’s only 1 active per parent_id. However, I’m being forced to add :id in the group_by so the count is never > 1. Was wondering if anyone had any thoughts on how to solve this one? https://gist.github.com/willc0de4food/77166ed984e2f4792dd0c024e2f782f0
[19:06:04] Malgorath: tbuehlmann, basically I am trying to reference another process_step in a each loop. I have <% process_category.process_steps.each_with_index do |process_step, si| %> and I want to have the title of a process_step display
[19:06:41] Maletor: Can anyone confirm my findings? I believe around_action is not *always* called after a before_action. If you define a around_action in a parent class then a before_action in a subclass the around_action gets called first.
[19:10:50] Malgorath: tbuehlmann, basically what I am doing is the same in php as calling a $data[$id]['title'] where $id will be the value of another $data[0]['id']
[19:11:04] pLaTo0n: has joined #RubyOnRails
[19:11:07] Malgorath: if that makes sense
[19:12:05] zacts: has joined #RubyOnRails
[19:13:35] ivanskie: has joined #RubyOnRails
[19:14:02] ivanskie: oh gawd i just realized something
[19:14:21] jhfisc: has joined #RubyOnRails
[19:15:36] ivanskie: I've been pronouncing railties in my head like (royalties, tees) for the past few years. was just looking at rails code and like how is this word a play on words in rails? end then it dawned on me
[19:15:51] ivanskie: rail ties. f$$ #killmenow
[19:16:19] chimkan: has joined #RubyOnRails
[19:18:37] ivanskie: railtees *sigh*
[19:19:40] hahuang65: has joined #RubyOnRails
[19:28:46] tbuehlmann: Malgorath: if there's a loop, then the title should just be process_step.title, right?
[19:29:52] Malgorath: tbuehlmann, what I have is a field called :dependency that references another process_step. so I what I am trying to do is call the title from the dependency field
[19:30:07] Malgorath: Can I have a a 1 to 1 relationship inside the same table? Like would that work?
[19:30:48] NoGodDamnIdea: has joined #RubyOnRails
[19:35:28] [Butch]: has joined #RubyOnRails
[19:40:48] netzfisch: has joined #RubyOnRails
[19:42:30] Malgorath: tbuehlmann, how would I do a 1 to 1 that would use the dependency field as the key?
[19:44:57] delgiudices: has joined #RubyOnRails
[19:46:39] Malgorath: In model add belongs_to :req, class_name: 'ProcessStep', foreign_key: 'dependency' then in view I do: <% unless process_step.dependency.nil? %> <strong title="<%= process_step.req.title %>">REQ</strong><% end %> and it works as expected
[19:46:51] brent__: has joined #RubyOnRails
[19:48:15] conta: has joined #RubyOnRails
[20:04:31] jottr: has joined #RubyOnRails
[20:04:53] lxsameer: has joined #RubyOnRails
[20:10:15] kt2: has joined #RubyOnRails
[20:14:27] gusrub: has joined #RubyOnRails
[20:14:27] knight33: has joined #RubyOnRails
[20:15:20] ascarter: has joined #RubyOnRails
[20:24:02] mikecmpbll: has joined #RubyOnRails
[20:27:36] theunraveler: has joined #RubyOnRails
[20:31:41] delgiudices: has joined #RubyOnRails
[20:35:07] agent_white: has joined #RubyOnRails
[20:41:00] delgiudices: has joined #RubyOnRails
[20:58:47] jscheel: has joined #RubyOnRails
[21:02:53] gusrub: has joined #RubyOnRails
[21:02:57] jottr: has joined #RubyOnRails
[21:03:19] mikecmpbll: has joined #RubyOnRails
[21:07:24] s2013: has joined #RubyOnRails
[21:08:24] s2013: hello folks
[21:08:24] s2013: Radar you around?
[21:11:01] baweaver: s2013 Likely not for a while.
[21:11:15] s2013: like forever while? :(
[21:11:30] baweaver: Like he's probably asleep at the moment in Australia.
[21:11:49] baweaver: though you could try asking your question anyways.
[21:12:23] jhfisc: has joined #RubyOnRails
[21:12:44] delgiudices: has joined #RubyOnRails
[21:14:44] hahuang65: if I return an enumerator as my controller's response, is it possible to also pipe that response somewhere, sort of how `tee` works in bash?
[21:15:04] hahuang65: basically I need to stream a CSV download to the user, but at the same time, log that CSV file somewhere for auditing purposes.
[21:16:19] wethu: has joined #RubyOnRails
[21:17:24] jhfisc: has joined #RubyOnRails
[21:23:34] jhfisc: has joined #RubyOnRails
[21:26:35] delgiudices: has joined #RubyOnRails
[21:28:47] amperry: has joined #RubyOnRails
[21:29:07] amperry: Hi folks. My client got an "incomplete response received from application" error; the logs said (Missing `secret_token` and `secret_key_base` for 'production' environment, set these values in `config/secrets.yml`). But as far as I can tell, they are set there. I checked the environment's SECRET_KEY_BASE in the shell ($ env| grep -i 'secret'), and it is correct. I was able to read ENV["SECRET_KEY_BASE"] in the console.
[21:29:13] arBmind: has joined #RubyOnRails
[21:29:20] amperry: As a workaround, I hard-coded the value in config/secrets.yml, but I have no idea why it wouldn't work the way it always has. The file is listed in .gitignore, so I don't see what changes I made in any code would have caused it to fail this way.
[21:29:38] jhfisc: has joined #RubyOnRails
[21:29:40] amperry: Are there any "usual suspects"?
[21:29:55] s2013: i dont have a question just wanted to say hi to my bestest friend in the world Radar
[21:30:25] amperry: s2013: Radar is certainly a boon to the community.
[21:30:42] s2013: thats an understatement
[21:31:12] amperry: I go for the dryly understated. All the time, because it's the absolute best.
[21:35:13] DoubleMalt: has joined #RubyOnRails
[21:38:16] hahuang65: I wonder how Radar would feel if Sonar showed up as a regular in this channel
[21:41:04] zacts: has joined #RubyOnRails
[22:01:40] jhfisc: has joined #RubyOnRails
[22:06:18] SteenJobs: has joined #RubyOnRails
[22:07:12] SteenJobs: are rspec questions allowed here or is there a dedicated channel?
[22:09:49] Papierkorb: SteenJobs: as I've seen rspec questions a few times in here, ask away. If it's not rails specific, you can also ask in #ruby instead
[22:10:29] quirkycoders: has joined #RubyOnRails
[22:11:00] SteenJobs: struggling with a specific spec, apparently “expect_any_instance_of” really means any instance of the given class, but only one particular instance - i want to check that any instance of my class receives a given method twice, with the expected args differing between each call
[22:11:49] SteenJobs: if i call “expect_any_instance_of(MyClass).to receive(:my_method).with(args)” twice, i get an error that two different instances received calls to :my_method
[22:13:23] hahuang65: SteenJobs: this seems like it could be code-specific. I was going to suggest you mock out your 2 instances and pass them into to whatever triggers those method calls and specifically call out expectations on each instance.
[22:13:46] hahuang65: but then I realized, maybe you don't have access to that where you are. If you show some of your code, maybe we can give better suggestions
[22:13:49] SteenJobs: yea if i could get my hands on an instance of the class it would definitely solve everything for me
[22:13:59] SteenJobs: ugh i wish i could show this code
[22:14:12] SteenJobs: i might just have to do something kinda hacky
[22:14:20] SteenJobs: and by kinda i mean really hacky
[22:14:30] cseder: has joined #RubyOnRails
[22:16:03] jhfisc: has joined #RubyOnRails
[22:17:44] zacts: has joined #RubyOnRails
[22:20:01] ascarter: has joined #RubyOnRails
[22:20:24] hahuang65: SteenJobs: :\
[22:20:30] jhfisc: has joined #RubyOnRails
[22:21:01] SteenJobs: hahuang65: the hack didn’t work anyway, tried using a block to store the passed args in an array, and then set an expectation on the array’s contents, but the array seems to be empty each time
[22:25:10] mostlybadfly: has joined #RubyOnRails
[22:30:59] Radar: GOOD MORNING
[22:31:17] Radar: hahuang65: We would probably have to have an Epic Battle™
[22:31:50] jhfisc: has joined #RubyOnRails
[22:41:06] ElektroBug: has joined #RubyOnRails
[22:41:54] ElektroBug: I am using paperclip for images. It is giving me errors url method not defined
[22:43:11] Radar: ELektroBug: !didntwork
[22:43:11] helpa: ELektroBug: What "didn't work"? Did your server not start? Did your computer explode? Did your webpage turn bright pink? Did your client not pay your bill on time? You may have to be more specific. A Gist (http://gist.github.com) of the code that doesn't work (and the error you are getting) will be helpful.
[22:44:51] delgiudices: has joined #RubyOnRails
[22:45:00] ElektroBug: Radar: I made a Image model which has an attachment field did migraions using the paperclip generator and rake db:migrate
[22:45:27] Radar: ELektroBug: Hm I could've sworn I asked for code.
[22:45:40] ElektroBug: Radar: one sec
[22:45:45] Radar: Thank you.
[22:48:43] jscheel: has joined #RubyOnRails
[22:49:09] ElektroBug: Radar: https://pastebin.com/SRAcxUZs the Image model
[22:49:29] ElektroBug: https://pastebin.com/KyJDshB1 helper using the model for generating image code
[22:49:46] Radar: !whypbsucks
[22:49:46] helpa: Pastebin sucks because it loads slowly, has ads which are distracting and has terrible formatting. Please use Gist (http://gist.github.com) instead.
[22:49:53] Radar: I'm pretty sure I asked for Gist too.
[22:50:05] ElektroBug: Radar okay one sec
[22:50:08] Radar: And where is the error?
[22:50:33] Radar: Also: you're calling the .file method but you've defined the attachment as ":pic" in your model.
[22:50:36] fnodeuser: has joined #RubyOnRails
[22:50:40] Radar: Line 54 of your helper.
[22:51:22] jhfisc: has joined #RubyOnRails
[22:52:59] Exuma: has joined #RubyOnRails
[22:53:20] ElektroBug: Radar: Thanks for help
[22:53:37] ElektroBug: Radar will keep in mind from next time to post code in gist
[22:54:18] Exuma: has joined #RubyOnRails
[22:58:41] jhfisc: has joined #RubyOnRails
[22:58:51] DLSteve: has joined #RubyOnRails
[23:04:44] jhfisc: has joined #RubyOnRails
[23:12:25] jhfisc: has joined #RubyOnRails
[23:18:51] fryguy: fucking i hate when I spend a while trying to figure out somethign and it turns out to be a kernel bug!!!
[23:24:34] xco: has joined #RubyOnRails
[23:26:07] ascarter: has joined #RubyOnRails
[23:31:19] alfie: has joined #RubyOnRails
[23:34:54] zacts|pi: has joined #RubyOnRails
[23:41:39] ghormoon: has joined #RubyOnRails
[23:42:54] s2013: has joined #RubyOnRails
[23:44:50] cjlarose: has joined #RubyOnRails
[23:45:50] jhfisc: has joined #RubyOnRails
[23:47:55] cjlarose: Old versions of the Rails Guides are unavailable right now. They'll all redirecting to the edge guides. See http://guides.rubyonrails.org/v4.2/. Is the code that runs that site available on Github somewhere? Wasn't sure where to open an issue
[23:50:45] Radar: cjlarose: Open it at rails/rails
[23:51:09] cjlarose: Will do! Thanks!
[23:51:11] Radar: fwiw, the 4.2 guides are the only broken oens
[23:51:44] cjlarose: Oh you're right. That's weird.
[23:51:45] jhfisc: has joined #RubyOnRails
[23:53:58] xco: hi. can someone help with this: https://gist.github.com/siaw23/28d3286815884c945f186956c7f03573#file-error-txt-L2 i added application.js file
[23:54:13] brent__: has joined #RubyOnRails
[23:54:16] xco: error appearred after upgrade rom 5.0.4 to 5.1.2
[23:58:41] Radar: xco: Probably removed in the latest version of bootstrap-sass.
[23:58:46] Radar: You probably upgraded bootstrap-sass.