teaearlgraycold

Activity Graph

Page 1 of 3 | Next »

2016-06-17

[04:10:15] teaearlgraycold: Ping timeout: 244 seconds
[04:18:17] teaearlgraycold: has joined #RubyOnRails
[18:20:12] teaearlgraycold: has joined #RubyOnRails
[18:30:12] teaearlgraycold: has joined #RubyOnRails
[18:34:42] teaearlgraycold: Ping timeout: 260 seconds
[18:43:15] teaearlgraycold: has joined #RubyOnRails

2016-06-16

[02:53:12] teaearlgraycold: Ping timeout: 272 seconds
[03:07:30] teaearlgraycold: has joined #RubyOnRails

2016-06-15

[19:10:03] teaearlgraycold: Ping timeout: 244 seconds
[21:20:15] teaearlgraycold: has joined #RubyOnRails
[21:28:54] teaearlgraycold: Ping timeout: 250 seconds
[21:30:16] teaearlgraycold: has joined #RubyOnRails
[23:00:33] teaearlgraycold: Ping timeout: 246 seconds
[23:02:35] teaearlgraycold: has joined #RubyOnRails

2016-04-13

[18:38:44] teaearlgraycold: Ping timeout: 252 seconds
[18:44:45] teaearlgraycold: has joined #RubyOnRails
[21:40:04] teaearlgraycold: Ping timeout: 264 seconds
[21:46:37] teaearlgraycold: has joined #RubyOnRails

2016-04-11

[22:19:14] teaearlgraycold: Ping timeout: 260 seconds
[22:29:41] teaearlgraycold: has joined #RubyOnRails

2016-03-30

[20:14:32] teaearlgraycold: Ping timeout: 260 seconds
[20:15:33] teaearlgraycold: has joined #RubyOnRails
[20:27:22] teaearlgraycold: Ping timeout: 260 seconds
[20:32:27] teaearlgraycold: has joined #RubyOnRails

2016-03-15

[15:11:14] teaearlgraycold: That's a set operation, not a conditional one
[15:11:31] teaearlgraycold: naftilos76: you mean like ERB?
[15:12:31] teaearlgraycold: [2, 3]. [1,2,3] | [2,3] is what you want
[15:13:31] teaearlgraycold: Abhijit: read up on all of the ruby operators while you're at it
[15:13:47] teaearlgraycold: naftilos76: what problem are you trying to solve
[15:16:31] teaearlgraycold: naftilos76: well if you're using the rails framework you should just put all of that in a partial and have rails use ERB templating on it.
[15:16:45] teaearlgraycold: You can however manually invoke the ERB methods if it's ERB formatted
[15:17:33] teaearlgraycold: naftilos76: if you could post the code it'd help
[15:21:22] teaearlgraycold: No unless you're doing something wrong
[16:40:20] teaearlgraycold: [Tyrant]: Junior rails dev here :P
[16:40:33] teaearlgraycold: So what web startup is this for?

2016-03-04

[15:14:41] teaearlgraycold: If I set an :expire_after value for my rails sessions, how do I read the remaining session time (either in the controller or through javascript).
[21:13:10] teaearlgraycold: You shouldn't have a column sometimes be for a relationship, and sometimes for stings
[21:13:33] teaearlgraycold: If you want a column to be for different relationships then use a polymorphic association
[21:13:58] teaearlgraycold: But if you need 1 column to do both you're probably doing something wrong /outside/ of the model
[21:15:31] teaearlgraycold: You could just store validated JSON in a column
[21:15:44] teaearlgraycold: Some database engines allow for JSON specifically
[21:16:19] teaearlgraycold: ddubs: if you're storing JSON as a column though you should probably have a custom validator that ensures the layout of the JSON
[21:16:44] teaearlgraycold: As validation is one of No SQL style dB's weaker points
[21:17:58] teaearlgraycold: I don't really understand your situation, but I think you want to structure it like this:
[21:18:34] teaearlgraycold: {"foo": {},"bar":{"id": 4, "properties": { ... }}}
[21:18:50] teaearlgraycold: So there's a property "foo" but it's not given any relations or data
[21:19:01] teaearlgraycold: But bar has an id attached and other stuff too
[21:19:15] teaearlgraycold: But you may not need IDs depending if the JSON is holding all of the relevant data
[21:20:24] teaearlgraycold: http://guides.rubyonrails.org/active_record_validations.html#custom-validators
[21:20:30] teaearlgraycold: ^ And use that too
[21:25:35] teaearlgraycold: siaw: where does it redirect to?
[21:25:58] teaearlgraycold: siaw: you should also post your view too
[21:31:51] teaearlgraycold: siaw: you should use byebug in the create action of your controller to figure this out. I can't really tell what's going on without having the full project, and you should learn how to debug as well
[21:32:11] teaearlgraycold: Just stick "byebug" before line 16 of the controller
[21:32:44] teaearlgraycold: It'll put you in a REPL and you can exit out of byebug by pressing "c"
[21:32:54] teaearlgraycold: Just if @account.errors is empty
[21:33:11] teaearlgraycold: Stuff Well you'd have to do @account.save then @account.errors
[21:33:28] teaearlgraycold: sorry, check if*
[21:37:36] teaearlgraycold: siaw: no it's a function, don't put quotes around it
[21:39:26] teaearlgraycold: It should show a REPL in the console. If it's not then you're not even reaching the controller
[21:40:30] teaearlgraycold: Make sure you have a route for that action (either with the statement 'resources :accounts' or post '/accounts' => 'accounts#create', as: ...' in config/routes.rb)
[21:41:23] teaearlgraycold: siaw: also keep an eye on the network analyzer. In Chrome you can see it by hitting F12
[21:41:31] teaearlgraycold: Then going to the Network tab
[21:41:46] teaearlgraycold: It'll show you what a webpage is doing, what errors it gets, etc.
[21:53:15] teaearlgraycold: smathy: classic
[21:55:32] teaearlgraycold: siaw: check @account.errors after running @account.save
[21:55:46] teaearlgraycold: You could just puts @account.errors before the render :new statement
[21:57:38] teaearlgraycold: Rafcio: you might be able to get NGinx to do that
[22:02:15] teaearlgraycold: siaw: you don't have a method for current_user defined
[22:03:03] teaearlgraycold: Unless some gem is taking care of that
[22:03:18] teaearlgraycold: I guess devise is

2016-03-02

[22:28:28] teaearlgraycold: Is there a good way to see when the current rails session cookie will expire in JS?

2016-02-27

[22:08:22] teaearlgraycold: Ping timeout: 276 seconds
[22:08:35] teaearlgraycold: has joined #RubyOnRails

2016-02-26

[17:20:50] teaearlgraycold: has joined #RubyOnRails
[20:48:07] teaearlgraycold: When I do a Model.all.includes(:foos) each |model|; model.foo - it seems that model.foo is creating a new query even though I preloaded foos
[20:48:34] teaearlgraycold: Is there a way to get |model| to retain its foo through the each block?
[20:49:53] teaearlgraycold: drale2k: that's pretty trivial
[20:50:25] teaearlgraycold: Just use the username to seed an RNG then get three 0-255 numbers from it in sequence
[20:51:05] teaearlgraycold: drale2k: how many colors do you have?
[20:52:45] teaearlgraycold: drale2k: one sec while I post to pastebin
[20:54:37] teaearlgraycold: http://pastie.org/private/29wkitugpmiihud8d6vabg
[21:04:44] teaearlgraycold: Well that won't select from a set, will just give you a random 24bit color
[21:05:02] teaearlgraycold: And doesn't use a username as a hash so it won't be consistent
[21:05:22] teaearlgraycold: If you need it in JS the idea is pretty simple and portable
[21:07:05] teaearlgraycold: Oh I suppose you're not referring to ''#' + Math.floor(Math.random()*16777215).toString(16);' and instead referring to the github thing

2016-02-24

[21:06:43] teaearlgraycold: So rspec is telling me there are pending migrations and throwing an exception when I call ActiveRecord::Migration.maintain_test_schema!
[21:07:13] teaearlgraycold: Although That method is designed specifically for handling migrations :P
[21:07:54] teaearlgraycold: I'm running a generator in my rspec helper file that generates a migration, but it's being called /before/ maintain_test_schema, so I wouldn't think that'd be an issue
[21:10:22] teaearlgraycold: tfitts: commenting out the generator and re running (with the old migration file still left un-migrated) the error still occurs.
[21:11:04] teaearlgraycold: Yeah for some reason it's running check_pending! and throwing PendingMigrationError. I guess that method isn't meant to migrate stuff for you?

2016-02-18

[20:12:09] teaearlgraycold: Ping timeout: 255 seconds
[20:13:07] teaearlgraycold: has joined #RubyOnRails
[22:52:47] teaearlgraycold: How do you create a directory in a generator?
[22:53:17] teaearlgraycold: I've tried just doing: directory 'path/to/new/folder' but it tells me it couldn't find the directory
[22:53:36] teaearlgraycold: Radar: yeah but I'm using ruby not bash
[22:59:40] teaearlgraycold: Seems like erb's not happy with my template. I'm trying to do erb over a HAML file so that might be an issue...
[22:59:42] teaearlgraycold: http://pastie.org/private/jnt7lote5uf7uwdxk90fmq
[23:00:26] teaearlgraycold: The resulting error: http://pastie.org/private/wt64cbqeszppm1fb3pkw

2016-02-12

[18:22:10] teaearlgraycold: So to avoid n+1s I've been adding .includes(:model) to different controller requests, but I'm /still/ getting queries for each of the n records returned
[18:29:57] teaearlgraycold: Bad code on my part
[18:35:09] teaearlgraycold: blooky: you can do that with JS
[18:35:21] teaearlgraycold: But if you want to do it on the server side it'd be pretty easy
[18:36:30] teaearlgraycold: Well first create a view that has a couple of input fields
[18:37:07] teaearlgraycold: Okay, then have them in a form that POSTs to a controller action
[18:37:37] teaearlgraycold: Have them come through as parameters, then get them with params[:word_one] etc
[18:38:00] teaearlgraycold: The algorithm for anagrams is simply to sort a character array and then compare the two resulting strings
[18:38:32] teaearlgraycold: Them redirect the user/return success or status after determining your result
[18:38:45] teaearlgraycold: Well it should probably be handled by AJAX in the first place
[18:39:07] teaearlgraycold: So you'll have some Javascript in the view that listens for an event that indicates you wish for server-side validation
[18:39:14] teaearlgraycold: Then makes the post itself
[18:39:31] teaearlgraycold: Then decodes a JSON formatted response and does something to the DOM according to the boolean
[18:39:52] teaearlgraycold: It'd be trivial to do this all in JS but I'm guessing you're just doing this as a learning exercise
[18:40:21] teaearlgraycold: Yeah so you want to do an ajax with JQuery or 'pure' JS
[18:40:55] teaearlgraycold: You can also try doing a form_for with remote: true
[18:41:11] teaearlgraycold: Then in the controller do respond_to do |format|; format.js { blah blah}; end
[18:41:24] teaearlgraycold: And then have seperate .js responses according to the anagram-ness
[18:42:08] teaearlgraycold: basically it'll download JS from the server and run it, so you can have one JS response that'll call alert('success'); and another that calls alert('failure');
[19:38:22] teaearlgraycold: If I have a reference to an attribute of a model how can I tell if it's an enum?
[19:40:31] teaearlgraycold: In a model, the declaration that an integer column is an enum
[19:41:10] teaearlgraycold: I can find out it's an integer faily easily, but how do I know if it's an enum?
[19:41:31] teaearlgraycold: Or alternatively, is there a method to get all attributes of a model with enums turned into their respective strings?
[19:46:27] teaearlgraycold: Don't you think that's being deliberately obtuse?
[19:48:06] teaearlgraycold: Class Model < ActiveRecord::Base; enum type: [:one, :two, :three]; end
[19:48:17] teaearlgraycold: Like that. One of those.
[19:48:28] teaearlgraycold: Ignoring that though
[19:52:25] teaearlgraycold: So if I do something like Model.first.attributes how do I get the symbol associated with all enums in the attribute hash
[19:52:37] teaearlgraycold: Because it seems like it's only giving out integers
[19:53:03] teaearlgraycold: I could either 1. iterate through all keys in the hash and check if they correspond to a defined enum as specified
[19:53:20] teaearlgraycold: Or 2. get the symbols
[19:53:35] teaearlgraycold: Well AR does other shenanigans to abstract away what the dB actually sees
[19:53:47] teaearlgraycold: Like if you're using SQLite
[19:54:57] teaearlgraycold: I don't think SQLite's great for all purposes either, I'm just saying if you are using it ruby hides the true class types from you
[19:55:28] teaearlgraycold: So it translating enums defined in the model wouldn't be too far of a step to take
[19:55:47] teaearlgraycold: ie: 1.class # => Fixnum
[19:56:29] teaearlgraycold: And they don't need to be, but they act as a mapping between two types
[19:57:40] teaearlgraycold: When you add "enum foo: [:bar]" to a model you're mapping integers to symbols, or vice-versa
[19:58:24] teaearlgraycold: :bar is a symbol
[19:58:30] teaearlgraycold: It corresponds to an integer value of 0
[20:40:12] teaearlgraycold: Well you guys are going to hate me, but this is what I did: http://pastie.org/private/qy4q8oocgjvtv7eyxtbb7g
[20:42:02] teaearlgraycold: beingjohnm: how are you calling the assets from the HTML?
[20:42:27] teaearlgraycold: nikk_: if it's specific jobs you could have them close out if Rails.env.production? fails
[20:42:58] teaearlgraycold: Or just do something like JobName.perform_later param if Rails.env.production?
[20:43:54] teaearlgraycold: beingjohnm: pretty sure you'll want to put the images in /vendor/assets/images/frontend then call it with "frontend/All-0012.jpg"
[20:44:32] teaearlgraycold: Seems reasonable
[20:45:03] teaearlgraycold: beingjohnm: dont' think that's the "rails way tm"
[20:45:08] teaearlgraycold: Or more so - the sprockets way
[20:45:51] teaearlgraycold: You put all js files of a certain set in /assets/javascripts, all css files of that set in /assets/stylesheets
[20:46:50] teaearlgraycold: What do you mean?
[20:47:19] teaearlgraycold: The front end is part of the app? And they're all part of your rails site so both should be Rails-y
[20:48:25] teaearlgraycold: beingjohnm: you should probably just use seperate layout files then
[20:48:46] teaearlgraycold: And in the layout for the "front end" you call a different application.css and application.js

2016-02-10

[21:25:08] teaearlgraycold: So I have a default scope for my model ('updated_at: :desc'), but when I try to explicity sort it in the controller by a field it seems like the scope I specify has no effect
[21:26:07] teaearlgraycold: Disabling the default scope in the model gives the desired effect, but then it won't have the default sorting I'm looking for when no sort field is specified
[21:27:00] teaearlgraycold: But why not store as a datetime?
[21:28:20] teaearlgraycold: smathy: I want a default scope /unless/ another scope is specified
[21:29:28] teaearlgraycold: How can I disable the scope? When I said I disabled it I commented it out :/
[21:31:30] teaearlgraycold: lost_soul_: oh okay. Yeah just do a string and add verifies :year, with: /\d{4}/ or something like that
[21:32:34] teaearlgraycold: or /[12][90]\d{2}/

2016-02-08

[17:41:11] teaearlgraycold: So I have this weird CSS issue. In development my Bootstrap 3 buttons have ~5px of spacing between each of them, but in production they have no spacing. What's odd is that in both cases neither has a specified margin property.
[17:42:01] teaearlgraycold: Setting margin-right: 5px; just /adds/ to the existing margins in development, so I'm not sure what's going on
[17:44:47] teaearlgraycold: Oh, elastic beanstalk
[17:46:38] teaearlgraycold: bpr_admin: this seems to have something about the database.yml in it: http://superuser.com/questions/510593/elastic-beanstalk-rails-application-with-git-source-and-deploy-hooks

2016-02-01

[18:58:35] teaearlgraycold: Why am I still logged into my rails app if I delete the rails_session cookie?
[18:58:47] teaearlgraycold: It seems like even if I delete it on the next request I get it back
[19:00:31] teaearlgraycold: I think it's just storing my user ID
[19:00:41] teaearlgraycold: But I don't really know for sure
[19:02:02] teaearlgraycold: You should post some contextual code

2016-01-31

[12:28:37] teaearlgraycold: has joined #RubyOnRails

2016-01-29

[15:06:06] teaearlgraycold: Is there an easy way to connect rails to an existing dB with non "rails-y" table and column names?
[19:06:00] teaearlgraycold: ferr: I'm using full calendar
[19:06:06] teaearlgraycold: It's got a lot of features
[19:06:27] teaearlgraycold: I pass it events using the gon gem
[19:11:09] teaearlgraycold: I'm using gem 'fullcalendar-rails'

2016-01-28

[16:52:34] teaearlgraycold: Is there any way to have some kind of high level view template in rails? What I want is something where I can reference a partial and then pass theit blocks of HTML to insert into specific portions
[16:53:20] teaearlgraycold: I know about content_for. I guess I could leverage that...
[16:53:27] teaearlgraycold: I kinda want soemthing like a Java interface
[16:53:46] teaearlgraycold: So you reference this partial and then you have certain requirements that need to be met
[16:54:39] teaearlgraycold: reckoner: oh, neat
[16:55:10] teaearlgraycold: That'll only let me do one yield though, right?
[16:55:56] teaearlgraycold: Maybe it'll work for me. Thanks
[17:30:41] teaearlgraycold: a1fa: how are you importing the datepicker JS file into the view?
[17:31:13] teaearlgraycold: Or - the datepicker JS and the JS that calls datepicker
[17:31:26] teaearlgraycold: Anyone know why I get this: http://pastie.org/private/7jqzep4peqv74e1wwobrg ?
[17:32:40] teaearlgraycold: a1fa: if you're manually calling javascript_include_tag you need to add "data-turbolinks-track" => true as an option
[17:34:27] teaearlgraycold: brahman: you're not using source control?
[17:35:14] teaearlgraycold: tbuehlmann: a1fa: or use the JQuery turbolinks patch and do $(function() { ... });
[17:36:47] teaearlgraycold: brahman: why couldn't you just get the old version out of source control though?
[17:36:56] teaearlgraycold: Not at your workstation I guess
[17:38:59] teaearlgraycold: brahman: pretty sure there's no way to get that template out of memory - there shouldn't be a way to get rails to give you the pre-processed contents of a template
[17:39:03] teaearlgraycold: For security reasons
[17:39:55] teaearlgraycold: reckoner: http://pastie.org/private/7jqzep4peqv74e1wwobrg - any idea?
[17:42:10] teaearlgraycold: brahman: you can take the HTML source of course
[17:42:23] teaearlgraycold: Then build in any ruby manually

2016-01-27

[16:18:42] teaearlgraycold: Can you not have multiline when statements in ruby?
[16:19:56] teaearlgraycold: This doesn't work for me: http://pastie.org/private/kfirdiwwbwojt2acwlwg
[16:20:00] teaearlgraycold: Always returns false
[16:21:11] teaearlgraycold: So "when String" will still work?
[16:23:40] teaearlgraycold: And if I want to get the current class as a string from within a concern, that's self.name?
[16:24:30] teaearlgraycold: a1fa: I use that in my rails project
[16:25:00] teaearlgraycold: Add this to your gemfile:
[16:25:04] teaearlgraycold: gem 'bootstrap3-datetimepicker-rails', '~> 4.17.37'
[16:25:32] teaearlgraycold: deur-: I never do it

2016-01-15

[22:07:26] teaearlgraycold: rhizome: hearing belongs_to appeal. It seems that states aren't set to belong to anything, even though they store IDs. That's never been an issue before, but I can add in some belongs tos there
[22:07:37] teaearlgraycold: Like State belongs_to appeal, State belongs_to Hearing
[22:12:57] teaearlgraycold: rhizome: what do you mean? If a model posesses foreign keys it doesn't use belongs_to? That's what I've been doing for months - with success.
[22:13:56] teaearlgraycold: Yeah I'll try adding that cause I realize it should be there in the state model
[22:14:47] teaearlgraycold: Oh wait shit no
[22:14:52] teaearlgraycold: I forgot what I'm doing
[22:16:10] teaearlgraycold: rhizome: yeah I tried looking for one but didn't find any good ones actually
[22:19:57] teaearlgraycold: rhizome: yeah this looks neat.
[22:20:22] teaearlgraycold: Would this work fine for me with 40 states each with specified outgoing edges and temporal transistions?
[22:23:08] teaearlgraycold: It might be too late to add that in though :/ IDK seems like there should be an easy solutino to my original problem
[22:24:55] teaearlgraycold: That might get out of control quickly. One entity has 15+ states.
[22:25:14] teaearlgraycold: I might just add (to the Stateful concern) a in_state(state) method
[22:37:31] teaearlgraycold: rhizome: It seems that Appeal.in_state(:appeal_pending).includes(:hearings).in_state(:hearing_cancelled) is trying to apply both in_state scopes to Appeals
[22:37:50] teaearlgraycold: Is there a good way to specify the scope is for the hearings?
[22:39:17] teaearlgraycold: rhizome: it seems to work for me
[22:39:24] teaearlgraycold: Here's my scope: scope :in_state, ->(state_name = nil) { includes(:state).where('states.name' => state_name) }
[22:39:44] teaearlgraycold: When doing Model.in_state(:state_name) it gets the right results