Activity Graph

Page 1 of 1


[00:50:14] hnanon_: has joined #RubyOnRails
[00:50:56] hnanon_: Read error: Connection reset by peer


[14:26:41] hnanon_: has joined #ruby
[14:27:13] hnanon_: I have a series of variables like: a = 26, b = 25, c = 24, etc. (the values are actually different).
[14:27:37] hnanon_: I want to loop through a array of letters and replace each element with the corresponding variable value.
[14:27:52] hnanon_: So, I suppose I could do something like:
[14:30:05] hnanon_: Papierkorb: I'm receiving a list of amino acids, those amino acids have a certain numeric property, I want to ultimately do math on each numeric value of the aa.
[14:30:38] hnanon_: I was going to use .map and a bunch if if/else.
[14:34:08] hnanon_: Papierkorb: I'm not following. I have an array sequence = ["a", "b", "c"]. I initially planned on doing { |aa| if aa == "a" aa = 1, if aa == "b", aa = 2}
[14:34:15] hnanon_: Something like that.
[14:35:00] hnanon_: But I also have a list of variables: a = 1, b = 2, etc.
[14:35:21] hnanon_: So I thought there might be a simpler way using the predefined variables.
[14:38:11] hnanon_: Papierkorb: Would a bunch of if/else (22 or so of them) be the more simpler or "ruby" way?
[14:38:45] hnanon_: What if the I had an array of hashes?
[14:39:17] hnanon_: [{"a": 1}, {"b":2}]
[14:39:46] hnanon_: How could I use that to replace the values in the sequence (or create a new sequence, actually).
[14:41:56] hnanon_: Papierkorb: This looks like it solves it:
[15:12:38] hnanon_: Papierkorb: I now have this:
[15:12:59] hnanon_: But .map is returning nil for each element in the array.
[15:13:16] hnanon_: In other words, the hash lookup is not working.
[15:15:17] hnanon_: Papierkorb: [1, 2, 3]
[15:15:58] hnanon_: Line 5 should be values[:aa]
[15:21:05] hnanon_: Papierkorb: Thank you.
[15:21:10] hnanon_: It's working now.
[17:01:34] hnanon_: Ping timeout: 260 seconds


[10:00:01] hnanon_: has joined #ruby
[10:00:59] hnanon_: I have a string that I want to sequentially append numbers to. Is a regex the simplest way? For example:
[10:01:26] hnanon_: where I look for a "-" in the atring, if it exists, extract the number, convert it to an integer, add one to it, convert it to a string, then append it?
[10:19:32] hnanon_: muelleme: The string looks like "234253"
[10:19:41] hnanon_: All numbers, in other words.
[10:20:30] hnanon_: Oh, wow. .next does indeed work.
[10:20:33] hnanon_: Thank you.
[10:42:06] hnanon_: Quit: Page closed


[00:22:00] hnanon_: has joined #RubyOnRails
[00:22:15] hnanon_: Client Quit
[01:17:10] hnanon_: has joined #RubyOnRails
[07:46:49] hnanon_: Ping timeout: 260 seconds
[21:02:53] hnanon_: has joined #RubyOnRails
[21:14:16] hnanon_: I'm having trouble rescuing a Stripe exception.
[21:17:53] hnanon_: This is what I have tried so far:
[21:17:55] hnanon_:
[21:18:20] hnanon_: I see the error message from the logger.
[21:19:08] hnanon_: However, I'm getting the error message "NameError (undefined local variable or method `errors' for #<Class:0x007fb904d56000>):"
[21:20:46] hnanon_: Presumably, this is because I can't do errors.add :base in a class method (self.create_stripe_customer).
[21:21:38] hnanon_: But I can't think of any other way to do it without the line...
[21:21:40] hnanon_: Card.create_stripe_customer(@user, @card.stripe_token, @card)
[21:21:55] hnanon_: my create action in my users controller.
[21:22:12] hnanon_: I need to pass all three of those arguments.
[21:23:21] hnanon_: My goal is to add the exception error message to base and display it to the user.
[23:02:52] hnanon_: Radar: Hey.
[23:27:54] hnanon_: Radar: Nothing much. Just wanted to say hello.
[23:28:33] hnanon_: Radar: I don't want to just say hi when I'm facing a Rails problem.
[23:58:38] hnanon_: Ping timeout: 260 seconds


[02:34:27] hnanon_: I have this line in my create, after save: @user = @company.users.first
[02:34:32] hnanon_: Followed by @company.set_user_role(@user)
[02:35:20] hnanon_: In my Company model in the set_user_role method I have: user.update(role: 0)
[02:35:45] hnanon_: In the create action, after saving the company.
[02:39:40] hnanon_: Gist:
[03:02:48] hnanon_: Ping timeout: 246 seconds


[01:39:00] hnanon_: has joined #RubyOnRails
[01:45:13] hnanon_: I have "status" as an enum.
[01:45:35] hnanon_: When I update the status field in a form I get an error: '1' is not a valid status
[01:47:57] hnanon_: Working. Thanks.
[02:09:09] hnanon_: I have a strip_currency method in my model that gsubs out nonnumerics.
[02:09:53] hnanon_: I have three attributes that are currency values that I want to pass to that method on create, before saving.
[02:10:28] hnanon_: Can I do something like @deposit.strip_currency(actual_amount)
[02:11:01] hnanon_: Where actual_amount is the name of one of the attributes.
[02:11:33] hnanon_: And strip_currency is strip_currency(currency)
[02:15:28] hnanon_: When I try that I get: undefined method `gsub!' for :actual_amount:Symbol
[02:16:31] hnanon_: Then back to a decimal?
[02:20:48] hnanon_: I used currency.to_s.gsub!(/[^0-9,\.]/, '').to_d and it's working fine now.
[02:40:50] hnanon_: I'm splitting the date_select components with:
[02:41:29] hnanon_: However, the :selected option doesn't seem to be supported. Is that the case?
[02:43:03] hnanon_: It's supported when using date_select.
[02:44:14] hnanon_: Radar: I looked at that. It throws off my design.
[02:44:34] hnanon_: Is it really bothering you that I tried something else?
[02:44:56] hnanon_: Radar: strange.
[02:46:09] hnanon_: tubbo: Wow.
[02:48:13] hnanon_: Radar: I apologize for coming off as unappreciative. I think you know by now that I appreciate all the help you've been giving me.
[02:49:17] hnanon_: Radar: No need to thank me for that, if you're serious.
[02:49:35] hnanon_: Radar: It's a form at /new.
[02:50:07] hnanon_: Radar: Did you see my gist above?
[02:50:49] hnanon_: Hahaha. I can't win.
[02:51:35] hnanon_: sevenseacat: I'm getting to that, thanks...just busy defending myself.
[02:57:19] hnanon_: Radar: Sorry...battery's almost dead...
[02:57:26] hnanon_: I'll be back shortly.
[02:57:46] hnanon_: Radar: Sorry. But thanks, though. Seriously.
[03:02:03] hnanon_: Ping timeout: 246 seconds


[02:42:08] hnanon_: has joined #RubyOnRails
[02:45:43] hnanon_: I have: <%= link_to (image_tag deposit.receipt.url(:thumb)) %>
[02:45:52] hnanon_: I want to link to the actual image, though.
[02:46:14] hnanon_: I'm not sure what the second parameter of should be for the link_to helper.
[02:48:53] hnanon_: Failbit: I want to show the image and link to it.
[02:50:03] hnanon_: I used: <%= link_to (image_tag deposit.receipt.url(:thumb)), deposit.receipt.url(:thumb) %>
[02:50:16] hnanon_: It's working thanks to your hint.
[03:04:57] hnanon_: Ping timeout: 246 seconds


[01:19:33] hnanon_: has joined #RubyOnRails
[01:19:51] hnanon_: I have: <%= f.collection_select(:essay_id, @essays, :id, :full_name, { prompt: true }, { class: "form-field" }) %>
[01:20:08] hnanon_: Getting the error:
[01:20:13] hnanon_: undefined method `map' for nil:NilClass, on create
[01:20:27] hnanon_: What is it saying is nil?
[01:20:46] hnanon_: Review controller, create action.
[01:21:05] hnanon_: That line above.
[01:21:45] hnanon_: sevenseacat: But it's not.
[01:22:02] hnanon_: Hmm. 1 sec.
[01:23:34] hnanon_: sevenseacat: I have @review = in my create and essay_id in those params. In the new action I have @essays = Essay.all
[01:24:12] hnanon_: I though it just had to be initialized?
[01:25:15] hnanon_: Failbit: Yes, I agree, but in this case I need it.
[01:25:59] hnanon_: So, I need to define @essays in the create?
[01:26:03] hnanon_: Yes, 1 sec.
[01:28:56] hnanon_: trace:
[01:31:16] hnanon_: sevenseacat: Won't the essay_id in review_params be used in the create action?
[01:32:20] hnanon_: sevenseacat: @essays in the new action lists all the essays in a collection_select. After picking one, shouldn't that be used. I see the essay collection at /new.
[01:33:19] hnanon_: sevenseacat: So how do I pass that selected option?
[01:33:33] hnanon_: It should no longer be @essays in the create then.
[01:34:25] hnanon_: But I don't want all of those options to be in the create.
[01:35:32] hnanon_: Why? I only want the one selected to be passed to create.
[01:38:45] hnanon_: sevenseacat: I think I understand now.
[01:39:38] hnanon_: FailBit: Do you sleep?
[02:02:52] hnanon_: Ping timeout: 246 seconds


[00:04:26] hnanon_: has joined #RubyOnRails
[00:07:04] hnanon_: The following line works as expected:
[00:07:07] hnanon_: @essay_one_first_draft_reviews = essays: { number: 0, stage: 0 })
[00:07:19] hnanon_: However, this line is giving me an error:
[00:07:27] hnanon_: @essay_one_final_draft_reviews = essays: { number: 0, stage: 1 })
[00:07:34] hnanon_: first vs final
[00:07:50] hnanon_: Error: undefined method `reviews' for nil:NilClass
[00:07:57] hnanon_: I can't figure out why.
[00:32:45] hnanon_: pontiki: I figured it out. I didn't have a set_user method on that action.
[00:55:46] hnanon_: Ping timeout: 246 seconds
[18:16:31] hnanon_: has joined #RubyOnRails
[18:17:32] hnanon_: Essay belongs to User, Review belongs to User, Review Belongs to Essay
[18:17:49] hnanon_: I want to count the number of reviews a user has written for a particular essay.
[18:17:59] hnanon_: user.essays.where(number: 0, stage: 0)
[18:18:25] hnanon_: That's giving me an incorrect number, though.
[18:22:26] hnanon_: huck5: Let me try that.
[18:23:42] hnanon_: Actually, I don't think that will work; I need user reviews for a type of essay with the conditions above.
[18:24:00] hnanon_: number: 0, stage: 0
[18:28:47] hnanon_: Failbit: It still gives me the wrong number.
[18:29:38] hnanon_: Let me double check the number of reviews from the console...1 sec.
[18:33:11] hnanon_: How do I show all records in the console?
[18:39:33] hnanon_: I think I have some orphaned records from previous deletions.
[18:39:50] hnanon_: I just added ", dependent: :destroy" to my models to prevent that (I hope).
[18:42:13] hnanon_: So, I have: has_many :essays, dependent: :destroy
[18:42:25] hnanon_: If I delete all users, should that also delete all essays?
[18:46:58] hnanon_: centrx: I didn't :(
[18:48:44] hnanon_: Through the console.
[18:48:54] hnanon_: User.destroy_all
[18:52:16] hnanon_: I did not reload! the console until after destroying.
[18:59:30] hnanon_: rushed: Yup, I think that's what happened.
[18:59:54] hnanon_: Failbit: I believe it's working now. Thank you.
[19:00:14] hnanon_: And thanks centrx and and rushed.
[19:00:58] hnanon_: rhizome: I've yet to write a single test. I'm still trying to get the basic down.
[19:36:49] hnanon_: Ping timeout: 246 seconds


[00:21:06] hnanon_: has joined #RubyOnRails
[00:52:43] hnanon_: Ping timeout: 246 seconds


[23:29:00] hnanon_: has joined #RubyOnRails
[23:29:18] hnanon_: Is there something like find_by_created_at_month?
[23:40:39] hnanon_: If I have a unix epoch time I can convert to a timestamp using
[23:41:08] hnanon_: d =
[23:41:20] hnanon_: Then I do d.year and I get the year.
[23:41:31] hnanon_: If I do d.month, I get the month.
[23:41:42] hnanon_: How can I get the month with a leading zero?
[23:43:20] hnanon_: has joined #RubyOnRails
[23:43:43] hnanon_: Not cool, Radar!
[23:44:21] hnanon_: I was typing "WOW! ByStar looks awesome!"
[23:45:02] hnanon_: What about my leading zero question?
[23:45:29] hnanon_: Radar: I do not want to trim it.
[23:45:45] hnanon_: Radar: d.month trims it.
[23:49:01] hnanon_: Radar: Does ByStar let me do by_year_and_month?
[23:52:32] hnanon_: Radar: Cool.
[23:52:46] hnanon_: Crap, battery's almost dead.
[23:52:54] hnanon_: I was making good progress too.
[23:59:16] hnanon_: Ping timeout: 246 seconds


[00:25:13] hnanon_: Ping timeout: 246 seconds


[23:13:36] hnanon_: has joined #RubyOnRails
[23:14:02] hnanon_: I got disconnected...
[23:14:23] hnanon_: Radar: Branch initially created add some features to the signup page. Then, I move on. Later, I want to add more features to the signup page.
[23:14:51] hnanon_: I missed it...
[23:30:33] hnanon_: Store US currency as a decimal or use cents (integers)?
[23:35:32] hnanon_: Radar: So, if a user enters $17.43 in a form, simply multiply it by 100 and store it?
[23:36:27] hnanon_: Radar, yes, of course without the dollar sign.


[15:58:08] hnanon_: has joined #RubyOnRails
[15:59:30] hnanon_: Client Quit
[15:59:55] hnanon_: has joined #RubyOnRails
[16:00:37] hnanon_: I'm having some problems with an "algorithm."
[16:01:10] hnanon_: My app accepts a csv file and imports the records.
[16:02:10] hnanon_: They are commission payments. However, the payments have certain types: one-time payment, multi-month payments.
[16:03:26] hnanon_: I reconcile the payments against a master csv file.
[16:04:56] hnanon_: Nevermind: It's too complicated to explain.
[16:53:45] hnanon_: I have the following code in my model:
[16:55:14] hnanon_: If I re-upload a csv file with soime changes the original record is updated, as expected. However, the newly created record (depending on the conditions) is not, and a new record is created when it should be updated.
[16:55:24] hnanon_: Line 9 creates the new record.
[16:55:50] hnanon_: If it exists, it should just be updated.
[17:21:04] hnanon_: Ping timeout: 246 seconds


[00:10:01] hnanon_: smathy, bricker: I'm back. Is the error syntax here correct:
[00:11:44] hnanon_: bricker: getting "undefined method `path' for nil:NilClass"
[00:12:02] hnanon_: I'm tested by trying to upload with no file selected.
[00:13:28] hnanon_: Radar: That's what I want to do!
[00:13:42] hnanon_: bricker: Yeah, LOL.
[00:14:17] hnanon_: It's nil because one wasn't selected.
[00:14:54] hnanon_: bricker: 1 day!
[00:15:26] hnanon_: smathy: It's in the model.
[00:17:20] hnanon_: Radar:
[00:17:29] hnanon_: smathy: Yes.
[00:17:52] hnanon_: bricker: That's what I'm stuck on. I don't know how to raise an exception and catch it in the controller.
[00:18:24] hnanon_: Radar: I'm just winging it.
[00:20:07] hnanon_: Radar: Tell me about line 4, please.
[00:21:11] hnanon_: Import template?
[00:21:35] hnanon_: Import is an action called from the form.
[00:22:15] hnanon_: search form in dealer_commissions/index
[00:23:50] hnanon_: Radar: So, render :index and return
[00:24:16] hnanon_: Trying simultaneously.
[00:26:59] hnanon_: Radar: It tried to render dealer_commissions/import with the dealer_commissions/index template
[00:28:11] hnanon_: Radar: Just so I understand, what variables?
[00:29:11] hnanon_: The instance variables?
[00:29:54] hnanon_: You guys are funny.
[00:30:03] hnanon_: Error: undefined method `index_url' for #<DealerCommissionsCo
[00:30:34] hnanon_: bricker: not me.
[00:30:49] hnanon_: And, yeah, what Radar said.
[00:31:11] hnanon_: Radar: Never apologize to me.
[00:32:44] hnanon_: Ok, another question:
[00:32:51] hnanon_: Nevermind.
[00:33:05] hnanon_: I'll toil with it first before asking.
[00:33:44] hnanon_: Thanks guys. I'll be back later.
[00:34:23] hnanon_: Hahaha. You saw what bricker said earlier. I've been trying to figure this out all day.


[20:25:18] hnanon_: I have a job that gets created (with an initial status of inactive). After creation, the user is sent to /customers/1/edit to add their cc details if they don't exist yet. After that, the user is sent to the show page of the job.
[20:25:26] hnanon_: I want to have a link the allow the user to then "publish" their job and make its status active.
[20:25:54] hnanon_: Should I create a new controller action and route, "publish?"
[20:26:07] hnanon_: And then just change the jobs status?
[21:12:04] hnanon_: I'm getting the error: No route matches [GET] "/jobs/12/update"
[21:12:21] hnanon_: I want to call a function in a model. I'm trying to update a model, so I'm just clicking an /update link.
[21:12:49] hnanon_: The controller update action looks like: if @job.update(job_params) @job.create_stripe_customer
[21:13:19] hnanon_: Where create_stripe_customer is the method in the Job model.


[20:28:09] hnanon_: Is the nested attributes line correct:
[22:12:47] hnanon_: In Rails console, how can I select the ith User?
[22:12:56] hnanon_: a = User...?
[22:13:28] hnanon_: Right, but what about 42nd?