istrasci

Activity Graph

Page 1 of 1

2019-06-12

[21:06:48] istrasci: has joined #RubyOnRails
[21:46:09] istrasci: Is there anywhere that lists the possible options for ActionMailer default_url_options? All I can find by googling is that you can set :host.

2019-05-29

[16:05:19] istrasci: Ping timeout: 256 seconds

2019-05-28

[17:45:52] istrasci: Quit: Page closed
[17:46:25] istrasci: has joined #RubyOnRails
[17:46:30] istrasci: I'm using Devise for authentication using a Users model. In my SessionsController, I'm overriding the #create method, but it appears a new User record is being created (if they've never logged in before) before I even get to the #create method. How is this happening? Because I need to preempt the record creation.
[17:55:21] istrasci: Ping timeout: 256 seconds
[18:44:43] istrasci: has joined #RubyOnRails

2019-05-24

[16:21:56] istrasci: has joined #RubyOnRails
[16:53:03] istrasci: I'm using Devise for authentication using a Users model. In my SessionsController, I'm overriding the #create method, but it appears a new User record is being created (if they've never logged in before) before I even get to the #create method. How is this happening? Because I need to preempt the record creation.

2019-05-22

[08:40:37] istrasci: Ping timeout: 256 seconds

2019-05-21

[06:34:19] istrasci: has joined #RubyOnRails
[06:41:20] istrasci: I'm trying to define a custom :after callback using `define_model_callbacks :my_method, only: [:after]`. I wrap the logic for :my_method in a `run_callbacks :my_method` block, but if that logic has an explicit return in it, the after callback doesn't execute. I need explicit returns in several of the logic branches, so what should I do?

2019-04-23

[18:39:23] istrasci: has joined #RubyOnRails
[18:40:13] istrasci: If I do a `redirect_to` and add a flash/alert/notice to it, is it possible to not have this show up as part of the URL?
[19:36:53] istrasci: Ping timeout: 256 seconds

2019-04-11

[20:26:17] istrasci: has joined #RubyOnRails
[20:28:17] istrasci: Can you do a .not on an existing scope? If I have scope :enabled, -> { where(enabled: true) }, can I somehow make scope :disabled somehow using not.enabled ?
[20:39:51] istrasci: Ping timeout: 256 seconds

2019-04-10

[00:35:13] istrasci: Ping timeout: 256 seconds

2019-03-07

[16:32:21] istrasci: has_and_belongs_to_many associations get a `collection=objects` method. What does this return? Is there any way for it to fail? I can't find any documentation for this.
[16:43:39] istrasci: Ping timeout: 256 seconds
[17:49:27] istrasci: has joined #RubyOnRails
[18:16:35] istrasci: Ping timeout: 256 seconds

2019-03-06

[17:20:55] istrasci: has joined #RubyOnRails
[17:41:45] istrasci: I have a model M with a `belongs_to :event` association. I also have the following scope: `scope :for_event, -> (e) { where(event: e).first }`. If I call the scope and no record with that event exists, the call returns all records. But if I call M.where(event: e).first directly, it returns nil. Why does the scope behave this way by returning all records?
[18:07:30] istrasci: Perhaps because of this behaviour: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/scoping/named.rb#L197

2019-03-05

[03:54:34] istrasci: has joined #RubyOnRails
[03:55:08] istrasci: Can anyone tell me what delete_all returns?
[03:56:15] istrasci: Or how can I make it deliberately fail in a unit test?
[03:59:48] istrasci: Radar: I have a method running a transaction, and I want to test all ways the transaction could fail and rollback.
[05:32:55] istrasci: Ping timeout: 256 seconds

2019-03-04

[19:34:49] istrasci: has joined #RubyOnRails
[19:45:54] istrasci: If I have the following scenario, how do I get all the unique colleges a student is associated with (preferably using an association instead of a method)? https://gist.github.com/istrasci/175a4f404735fb5661150b4cbeadcba2
[20:51:35] istrasci: Ping timeout: 256 seconds

2019-02-17

[06:31:45] istrasci: Ping timeout: 256 seconds

2019-02-15

[21:42:10] istrasci: has joined #ruby
[21:52:09] istrasci: When calling #any? or #all? on an Array, is there a guarantee of consistent evaluation order?
[21:55:58] istrasci: phaul: OK, thank you.
[21:58:31] istrasci: What is that pry command?
[21:59:33] istrasci: I have it installed. Is that an executable, or a command to run inside pry?
[22:01:48] istrasci: Ah, thanks. Didn't know about pry-doc gem.

2019-02-10

[10:11:11] istrasci: Ping timeout: 256 seconds

2019-02-08

[19:52:45] istrasci: has joined #ruby
[19:53:31] istrasci: Does ruby have official branding (esp. a color for the red colour)?
[20:15:11] istrasci: havenwood: Thanks! Where did youi find that?

2019-02-07

[23:15:11] istrasci: Ping timeout: 256 seconds

2019-02-06

[22:40:23] istrasci: has joined #RubyOnRails
[22:41:21] istrasci: If I have scope :important and :active, I can chain them to get the intersection of them (MyModel.important.active). How do I get the union of them?
[22:42:08] istrasci: Do I just use 'or'?? MyModel.important.or(MyModel.active) ?

2019-02-02

[04:45:01] istrasci: Ping timeout: 256 seconds

2019-01-30

[23:53:15] istrasci: has joined #RubyOnRails
[23:58:43] istrasci: Why is it that Rails stresses separation of stages for the database (typically, development, test, and production), but they all share one schema.rb file? This can cause you to get into these situations where different DBMSs for different stages step on each other's toes in the one schema.rb file.

2019-01-29

[20:37:25] istrasci: has joined #RubyOnRails
[20:37:46] istrasci: Is there any way in the Rails console to only show what SQL would be generated but not actually execute it?
[20:45:41] istrasci: havenwood: Like MyModel.where(active: true).to_sql ? Or do I need to make the command a string first?
[20:49:06] istrasci: havenwood: Works for that query, but not for a MyModel.find(1). Where is that method defined?
[20:58:58] istrasci: havenwood: Ah, thanks. Didn't know of that introspection.
[21:51:05] istrasci: Ping timeout: 256 seconds

2019-01-25

[05:07:21] istrasci: Ping timeout: 256 seconds

2019-01-22

[23:16:28] istrasci: has joined #RubyOnRails
[23:21:00] istrasci: I have an association User has_many :address. How can I make a second association has_one :home_address by giving a condition of the Address (like type = 'home')?

2018-10-04

[21:34:36] istrasci: has joined #ruby

2018-10-03

[17:29:01] istrasci: has joined #RubyOnRails
[17:31:04] istrasci: I'm trying to create a gem with a dash in the name, and include it (locally) into a Rails app. When I run rails console, I get "[error]: Error loading plugin 'my-gem'". If I create a similar gem with an underscore in the name, it works fine. Any ideas?
[18:04:53] istrasci: Ping timeout: 256 seconds

2018-06-08

[14:52:45] istrasci: Ping timeout: 260 seconds

2018-06-06

[17:14:14] istrasci: has joined #RubyOnRails
[17:14:24] istrasci: has left #RubyOnRails: ()
[23:02:23] istrasci: has joined #RubyOnRails

2018-04-06

[14:58:05] istrasci: For a has_one/has_many with conditions, what are the pros/cons of putting the conditions directly on the association vs. making a scope on the associated class and using that?
[22:20:38] istrasci: has left #RubyOnRails: ("PART #rspec :PING 1523053238")

2018-04-05

[19:48:17] istrasci: has joined #RubyOnRails
[19:52:52] istrasci: For a has_one/has_many with conditions, what are the pros/cons of putting the conditions directly on the association vs. making a scope on the associated class and using that?

2018-01-18

[15:19:54] istrasci: has left #RubyOnRails: ("PING 1516288794")

2018-01-17

[15:12:57] istrasci: has left #RubyOnRails: ("PONG :orwell.freenode.net")
[22:45:36] istrasci: has joined #RubyOnRails
[22:49:28] istrasci: If I run `rails g model --help`, I see that I can pass an option of "--primary-key-type=PRIMARY_KEY_TYPE". However, there is no further explanation of this, and Google is not helping much. Can anyone point me to some documentation on this?

2018-01-16

[20:56:17] istrasci: has joined #RubyOnRails
[21:07:57] istrasci: I have several models that I use across multiple Rails projects. I would like to extract these somehow to reuse them efficiently instead of copying the code to each project. Does this lend itself to creating a Rails Engine, or just a "regular" gem? I only need models and migrations; don't need controllers or views for them.

2017-12-15

[18:30:35] istrasci: has joined #RubyOnRails
[18:30:41] istrasci: How can I add a database comment to a table/column in a migration without dropping and re-adding it?
[22:20:57] istrasci: has left #RubyOnRails: ("PONG :hitchcock.freenode.net")

2017-10-04

[17:18:09] istrasci: has joined #RubyOnRails
[17:19:49] istrasci: Is there a way to unit test a Rails model for a database view?
[18:17:46] istrasci: Quit: Leaving.

2017-08-28

[17:25:50] istrasci: has joined #ruby
[17:26:32] istrasci: Is there a nice Hash method to do `hash.has_key?(:key) && hash[:key] == value` all at once?
[17:33:44] istrasci: Yeah, that wasn't working.
[17:34:10] istrasci: So the most important part is the comparison, but if the key doesn't exist in the first place, it barfs on you.
[17:36:25] istrasci: apeiros: Yeah, I tried hash.fetch(:key, false) == value. This will work unless the value you're comparing against is actually false.
[17:41:10] istrasci: Hmm, I think I knew Hash#[] returned nil for a non-existent key, but I was temporarily thinking it would raise an exception.
[17:42:05] istrasci: Must be a Monday morning.
[17:43:48] istrasci: OK, thanks everyone!
[17:47:58] istrasci: has left #ruby: ()

2017-05-17

[00:00:01] istrasci: Remote host closed the connection
[15:11:59] istrasci: has joined #ruby
[15:12:18] istrasci: HEREDOCs implicitly have a newline at the end that is often undesirable.  Is there a way to auto chomp! it in the syntax, or you just have to do it manually?
[17:27:19] istrasci: has left #ruby: ()

2017-05-16

[23:14:34] istrasci: has joined #ruby
[23:16:51] istrasci: HEREDOCs implicitly have a newline at the end that is often undesirable. Is there a way to auto chomp! it in the syntax, or you just have to do it manually?

2016-07-19

[21:33:03] istrasci: has joined #ruby
[21:34:15] istrasci: > {'a': 1} == {'a' => 1}
[21:34:15] istrasci: Using ruby 2.3.1, why is
[21:35:10] istrasci: So using the : syntax in a Hash forces the key to be a symbol?
[22:27:50] istrasci: has left #ruby: ()

2016-05-25

[00:00:01] istrasci: Remote host closed the connection

2016-05-24

[21:57:58] istrasci: has joined #RubyOnRails
[21:58:09] istrasci: Anyone know of any good tutorials on configuring a Rails Engine to test with RSpec?  I'm having a hell of a time figuring this out.
[22:04:00] istrasci: clandry94: And it covers Rails engines?
[22:07:27] istrasci: mikecmpbll: Thanks, I'll check it out.

2016-05-18

[05:37:24] istrasci: has joined #RubyOnRails
[05:42:32] istrasci: Hello, I used to be able to do ActiveRecord::Base.connection.disable_referential_integrity in Rails 3, but it looks like it's gone in Rails 4. Is there something equivalent?
[05:47:21] istrasci: Radar: You're right, I just found it in the docs.
[05:47:26] istrasci: But seems not to work.
[05:48:32] istrasci: Trying to drop a table within the disable_referential_integrity block, but it's still enforcing the RI.
[05:53:47] istrasci: Radar: https://gist.github.com/anonymous/0aa52abfa7bb5e1f713f94f9e1907d48
[05:55:32] istrasci: Radar: Does not db:drop delete the entire database?
[05:57:01] istrasci: Could be a bunch of other DB objects: stored procs, functions, triggers, etc.
[05:57:48] istrasci: But that's not the issue. That code should work.
[05:58:10] istrasci: (that's also not the whole rake task. Just the relevant section)
[07:11:06] istrasci: has left #RubyOnRails: ()

2016-04-22

[20:09:17] istrasci: has joined #RubyOnRails
[20:10:04] istrasci: Is it possible to make a Rails engine where the namespace is different than the actual engine name?
[20:11:33] istrasci: Well I did, and I can't get it to work. I make an engine called SomeApi, but I just want the namespace to be Some::. But if I do that, the rails console doesn't recognize Some:: as a namespace.
[20:11:57] istrasci: Wondering if I'm doing something wrong, or if it's just not possible.
[20:16:32] istrasci: I want to do `rails plugin new some_api —mountable`, but then have all the models, etc. as Some::Model1, Some::Model2, ...
[20:16:50] istrasci: tubbo: Not sure if that answers your question.
[20:17:50] istrasci: Yeah, I tried that too.
[20:20:19] istrasci: Let me make a gist.
[20:21:24] istrasci: helpa: My computer exploded. How can I configure my rails engine so that my computer doesn't explode? I guess that's my core question.
[20:27:58] istrasci: https://gist.github.com/istrasci/4b380cd8cf1dd7ac663fd86597f8115a
[20:30:14] istrasci: So I try to make the models in the Banner:: namespace, even though the whole engine is called RubyBannerApi. But it's not recognizing Banner::.
[20:54:00] istrasci: slash_nick: That, and I wanted the name to be more descriptive.
[20:54:26] istrasci: slash_nick: Yes, that is what I'm trying now.
[20:54:40] istrasci: I'm wondering if that's the only way.
[21:06:28] istrasci: Well, even if I renamed that directory, it still wouldn't find it.
[21:15:12] istrasci: *even when I renamed that directory
[22:04:32] istrasci: has left #RubyOnRails: ()

2016-04-21

[21:25:20] istrasci: has joined #RubyOnRails
[21:26:28] istrasci: When I do `rails plugin new <plugin name>`, why can't the <plugin name> have dashes in it? It only accepts underscores. But I want to create an engine that will be packaged as a gem, and many gem names have dashes. What gives?
[22:28:05] istrasci: has left #RubyOnRails: ()

2016-04-13

[16:34:27] istrasci: has joined #RubyOnRails
[16:58:18] istrasci: My Rails apps all have their own database (naturally), but also access a 3rd-party database. As such, they have models to this 3rd-party database. I want to DRY up these models to be reusable instead of copy-pasting them in each app. Would it be better to do this as a gem or as a Rails engine?
[17:05:59] istrasci: fryguy: Then package it as a gem after it's first created?
[17:08:01] istrasci: gasm: I'm not talking about your issue.
[18:38:10] istrasci: Ping timeout: 252 seconds

2016-02-29

[18:06:23] istrasci: has joined #RubyOnRails
[18:14:01] istrasci: I'm doing a Model.select to only send certain, non-sensitive properties to Javascript. However, I need to do an .includes() to get an associated relation, but apparently includes() cannot be used with select(). What's the best way around this?
[18:21:30] istrasci: cnk: Cool, I'll try that. Thanks.
[19:11:50] istrasci: has left #RubyOnRails: ()

2016-02-26

[18:47:38] istrasci: has joined #RubyOnRails
[18:48:50] istrasci: This is probably a n00b question, but if I have Author has_many :posts, and I delete a Post, why isn't removed from the author.posts collection?
[18:49:37] istrasci: tubbo: (-_____-) Hmmm, it's not.....
[18:50:18] istrasci: Ah, didn't know about reload. I'll try it. Thanks.
[19:25:30] istrasci: has left #RubyOnRails: ()

2016-02-18

[07:24:52] istrasci: has joined #RubyOnRails
[07:26:54] istrasci: I have a question about best practices? If my model has a has_many association, and I want a method that performs something on the entire collection (e.g., min, max, avg, etc.), is it better to make an instance method on the model, or a class method on the association model that accepts a collection, and call it with model.the_has_manys?
[07:29:43] istrasci: Where is the best-practices location for that method?
[07:31:49] istrasci: Assume the 'aggregate function' is not simply a generic mathematical one; some kind of customized logic.
[07:33:22] istrasci: Well, that's fine for those types. But I'm saying if the function isn't one of those.
[07:35:02] istrasci: What is "max" is not a numerical max, but a semantic one? For example, "president" > "governor" > "mayor". I need to make a custom operator for this; I'm not gonna use the database.
[07:36:47] istrasci: "aggregate function". Your words.
[07:36:56] istrasci: OK, let me start over.
[07:37:54] istrasci: rvanlieshout: In this case it's pointless because I know what you mean.
[07:38:49] istrasci: OK, I have a Student model, has_many TestScores. Assume for whatever reasons that I don't want to use built-in database aggregrates.
[07:40:07] istrasci: I could create a best_score method in Student that iterates directly over student.test_scores. Or I could create a class method max_score in TestScore, and call TestScore::max_score(student.test_scores).
[07:40:22] istrasci: Which is the better practice?
[07:45:06] istrasci: 1) You ignored my assumption. 2) This won't work if there is no aggregate DB function for the calculation.
[07:50:18] istrasci: OK, give me a minute.
[08:00:12] istrasci: https://gist.github.com/anonymous/2bb73e12ebfec09da3a6
[08:02:32] istrasci: Can you edit a public gist?
[08:03:17] istrasci: I don't want a string sort, I want a semantic sort.
[08:05:01] istrasci: I feel like you don't understand what a semantic sort is.
[08:06:32] istrasci: What's not clear about it?
[08:08:35] istrasci: I know that should work. I'm asking which is the better practice. The Student#highest_position or StudentGovernmentPosition.highest_position.
[08:13:41] istrasci: # I've already got the collection. Why go back to the DB?
[08:13:41] istrasci: student = Student.first
[08:13:41] istrasci: What's the reasoning for that? Aren't extra DB calls more expensive than just calculating at that point?
[08:13:52] istrasci: (I'm honestly asking)
[08:15:50] istrasci: rhizome: Yes, so if "highest" is an instance method, isn't it faster than if it were a scope that does another DB call?
[08:16:04] istrasci: (unless you're eager loading)
[08:26:30] istrasci: Quit: Leaving.

2015-10-07

[17:49:51] istrasci: has joined #RubyOnRails
[17:54:35] istrasci: How can I tell programmatically in a mailer if ActionMailer has been set up with a default 'to' address?
[17:58:07] istrasci: arup_r: There is no "default" property for ActionMailer; only a "default" method to set the default_params.
[18:03:32] istrasci: smathy, arup_r: default is a class method, that's why self.default wasn't working. Thanks
[18:03:41] istrasci: ActionMailer::Base.default
[18:06:06] istrasci: arup_r: Sorry, I missed the "class" in your example.
[19:28:24] istrasci: has left #RubyOnRails: ()
[22:29:59] istrasci: has joined #RubyOnRails
[23:11:23] istrasci: has left #RubyOnRails: ()

2015-10-06

[20:49:46] istrasci: has joined #RubyOnRails
[20:50:45] istrasci: In my config/application.rb, I'm setting a value from a yaml file. If the value is nil or the key doesn't exist in the yaml file, I want to display a message and kill the Rails server. How can I do this?
[20:59:06] istrasci: Yeah, that seems to work. Ha! Thanks.
[21:06:16] istrasci: has left #RubyOnRails: ()

2015-10-05

[16:32:20] istrasci: has joined #RubyOnRails
[16:33:12] istrasci: Is there any major difference between find_or_create_by and first_or_create?
[16:36:36] istrasci: gerep: What condition do you mean?
[16:56:40] istrasci: has left #RubyOnRails: ()

2015-09-18

[17:15:30] istrasci: has joined #RubyOnRails
[17:16:28] istrasci: Is there any reason why my model's before_update method is not being called?
[17:27:04] istrasci: capin: https://gist.github.com/istrasci/6ee535a36b10ae299cf8
[17:40:16] istrasci: Hang on....
[17:44:08] istrasci: Gist updated.
[17:57:04] istrasci: smathy: Where are you seeing that? Params has "update_phase"=>"save", and
[17:57:05] istrasci: if @update_phase.present? && @update_phase == 'save'
[17:57:05] istrasci: @update_phase = params[:update_phase] if params[:update_phase].present?
[17:59:37] istrasci: OK, it's not actually updating, but in my debugger (RubyMine), it won't break code execution in the before_update.
[18:07:45] istrasci: 2nd for using seed data.
[18:41:34] istrasci: has left #RubyOnRails: ()

2015-09-03

[18:34:13] istrasci: has joined #ruby
[18:35:30] istrasci: Is there a one-liner to to an Array group_by, and then sort the groups for each key by another constraint?
[18:39:52] istrasci: Ox0dea: Yeah, that's what I thought. Thanks.
[18:59:42] istrasci: has left #ruby: ()

2015-07-01

[20:58:56] istrasci: has joined #RubyOnRails
[21:06:18] istrasci: When you do `rails new my-new-app`, the file config/application.rb will have the module named "MyNewApp". Does anyone know where this string is constructed?
[21:14:45] istrasci: smathy: Thank you. Was trying to replicate the behaviour while missing some nuance.
[21:23:31] istrasci: has left #RubyOnRails: ()