Activity Graph

Page 1 of 2 | Next »


[08:50:15] thesubr00t: has joined #ruby
[08:51:03] thesubr00t: Hi guys ! What is the best approach to create a "datastore" class that can be accessed from the rest of an app ?
[09:11:15] thesubr00t: has joined #RubyOnRails
[09:13:14] thesubr00t: Hi ! I'm trying to build a simple Ruby app that has classe's with relationships based on 'foreign key' style without the use of database. I thought about creating a data object that will contain all the instance of other models.
[09:13:28] thesubr00t: What is the best approach to achieve this ?
[10:02:02] thesubr00t: Remote host closed the connection


[11:47:02] thesubr00t: has joined #ruby
[11:50:00] thesubr00t: What is the best approach to handle models relationships based on 'model_id' without databases ?
[11:50:30] thesubr00t: I tryed using ObjectSpace, but I don't feel that is the best approach
[12:02:29] thesubr00t: is there any toturial for ruby oodbms ?
[12:46:39] thesubr00t: Remote host closed the connection


[09:10:45] thesubr00t: has joined #RubyOnRails
[09:13:21] thesubr00t: How to optimize ActiveRecord::Base.connection.execute() for a large data. I'm experiencing a memory bloat on production loading ~ 50k row on a server with ~60kmb of RAM !
[09:14:50] thesubr00t: I use Postgresql
[09:24:09] thesubr00t: blackcross_, im storing the result in an Enumerator to stream it as a CSV file, something like "result.each_row { |row| yielder << CSV.generate_line(row) }. How to do that in chunks ?
[09:25:06] thesubr00t: result = ActiveRecord::Base.connection.execute(raw_sql)
[12:00:18] thesubr00t: Quit: Ex-Chat


[12:42:00] thesubr00t: has joined #RubyOnRails
[12:42:34] thesubr00t: Is there a helper to get the URI pattern for a specific path ?
[12:43:31] thesubr00t: dminuoso, yes programmatically
[12:44:12] thesubr00t: I need to send the pattern to a frontend client in a json response
[12:45:43] thesubr00t: dminuoso, I just need a helper like `something_path` to return the pattern, ex (users/:id)
[12:48:43] thesubr00t: dminuoso, well I'm sending a bunch of urls pattern to the front, so basically a clean approach is what I'm looking for.
[12:49:09] thesubr00t: dminuoso, but tell me what you have in mind ;-)
[12:57:03] thesubr00t: dminuoso, Okay thanks ! :-)
[13:15:48] thesubr00t: dminuoso, Thank you mate ! That will point me to the right direction
[13:32:05] thesubr00t: Ping timeout: 256 seconds


[15:27:39] thesubr00t: has joined #RubyOnRails
[15:31:06] thesubr00t: I'm trying to define a method inside a BaseSerializer class (parent class of other serializers) to transform all string attributes, but my implementation does not work. Please point me to the right direction. Here is a gist
[15:33:24] thesubr00t: it does not seem to define the methods as I want, but when i replace object.attributes.symbolize_keys.each_key with a list of manually typed attributes and move it out of the "attributes" method it works
[15:36:45] thesubr00t: Sure, here is the other class
[15:37:51] thesubr00t: sevenseacat, allcentury AMS v 0.10.6
[15:39:45] thesubr00t: allcentury, the object's list of attributes as symbols
[15:41:15] thesubr00t: sevenseacat, sorry its a hash with attributes as symbolized keys
[15:43:34] thesubr00t: sevenseacat, {:id=>30, :title=>"Some title here?", :kind=>"single_choice", :rank=>1, :allows_free_answer=>true, :survey_id=>3, :created_at=>Mon, 19 Mar 2018 13:53:15 CET +01:00, :updated_at=>Mon, 19 Mar 2018 13:53:15 CET +01:00}
[15:47:07] thesubr00t: sevenseacat, I'm expecting them to be defined on the child class's
[15:47:35] thesubr00t: Im trying to DRY that bit of code by defining it in the parent class
[15:47:52] thesubr00t: QuestionSerializer < BaseSerializer
[15:49:16] thesubr00t: sevenseacat, I'm expecting them to be defined on the QuestionSerializer class
[15:53:46] thesubr00t: sevenseacat, I test it by defining the method on the same class with no luck
[15:55:12] thesubr00t: The gsub part is not working
[16:04:10] thesubr00t: sevenseacat, allcentury
[16:06:53] thesubr00t: How to define it as a class method then?
[16:14:18] thesubr00t: allcentury, undefined method `id' for QuestionSerializer:Class
[16:14:43] thesubr00t: also object is not accessible here, I've changed it to self
[17:25:15] thesubr00t: Quit: Ex-Chat


[16:27:02] thesubr00t: has joined #ruby
[18:07:02] thesubr00t: Quit: Ex-Chat


[10:57:15] thesubr00t: has joined #RubyOnRails
[10:57:31] thesubr00t: has joined #ruby
[10:59:57] thesubr00t: I have an object services that I want to test using Rspec, but I don't know what is the proper way to do that.
[11:00:06] thesubr00t: Here is the service
[11:02:28] thesubr00t: dminuoso, the service is responsible for generating a CSV file, does that mean that I should compare the result with a pregenerated file?
[11:05:01] thesubr00t: dminuoso, I've tried with instance_double & recieve(:call) but I get:
[11:05:02] thesubr00t: received: 0 times with any arguments
[11:05:02] thesubr00t: expected: 1 time with any arguments
[11:05:02] thesubr00t: (InstanceDouble(ExportSurveyResponsesService::SurveyAnnexService) (anonymous)).new(*(any args))
[11:05:17] thesubr00t: same fr :new
[11:08:10] thesubr00t: dminuoso, here is the spec file so far export_survey_responses_service.rb
[11:09:18] thesubr00t: dminuoso, Its a Rails service
[11:10:37] thesubr00t: dminuoso, So how should I implement that?
[11:13:22] thesubr00t: dminuoso, Ok thanks :)
[11:14:59] thesubr00t: dminuoso, I get your opinion :)
[11:25:11] thesubr00t: Quit: Ex-Chat


[10:43:23] thesubr00t: has joined #RubyOnRails
[10:44:51] thesubr00t: Hi everybody, is there a way to generate resource path an ommit the namespace (ex: "/api/v1/users" => '"users") ?
[14:42:31] thesubr00t: Ping timeout: 252 seconds
[15:58:04] thesubr00t: has joined #RubyOnRails
[17:44:01] thesubr00t: Remote host closed the connection


[15:47:36] thesubr00t: has joined #RubyOnRails
[15:52:08] thesubr00t: How to combine two has_many associations into one AR relation?
[15:54:17] thesubr00t: lupine, Union & uniq
[15:54:41] thesubr00t: Will that preserve the AR relation?
[15:57:07] thesubr00t: lupine, can you please comment out the gist?
[15:58:53] thesubr00t: lupine, thanks
[16:57:33] thesubr00t: Remote host closed the connection


[16:58:07] thesubr00t: has joined #RubyOnRails
[17:01:09] thesubr00t: Hi folks, I'm using a gem which has a model with a belong_to association, since Rails 5 now requires the associated model by default, and I don't want to change this behaviour, How to override the association definition for that model to set 'optional: true'
[17:20:29] thesubr00t: tbuehlmann, Yes, but I only want to override that association and keep Rails behavior intact
[17:38:56] thesubr00t: tbuehlmann, exactly
[18:36:59] thesubr00t: Quit: Ex-Chat


[13:14:06] thesubr00t: has joined #RubyOnRails
[13:14:29] thesubr00t: Hi, Is there a way to use webpacker v2 with a Rails api?
[13:21:03] thesubr00t: dminuoso, I want to deploy the same code base once and serving a single server.
[13:22:23] thesubr00t: dminuoso, I know I can use RCA along with a Procfile, but I prefer using webpacker with React
[13:22:43] thesubr00t: react-create-app
[13:25:04] thesubr00t: dminuoso, Is there any cons for making two separate projects? Never experienced with that before, I used to ember-cli-rails
[13:26:02] thesubr00t: dminuoso, thank you.
[13:26:32] thesubr00t: By the way do you know any good react/redux boilerplate?
[13:27:24] thesubr00t: dminuoso, do you 'eject' often?
[13:28:15] thesubr00t: Big thanks :-)
[14:23:04] thesubr00t: Quit: Ex-Chat


[08:36:03] thesubr00t: has joined #RubyOnRails
[13:28:33] thesubr00t: Quit: Ex-Chat


[12:22:54] thesubr00t: has joined #ruby
[12:27:22] thesubr00t: I have an array "a" containing all the checkpoints (points), and another array "b" containing the coupled checkpoints (x -> y). How to sort the first array in a way that no y comes after x
[12:38:13] thesubr00t: Ping timeout: 268 seconds
[12:46:49] thesubr00t: has joined #ruby
[20:33:56] thesubr00t: Remote host closed the connection


[14:14:17] thesubr00t: has joined #ruby
[14:16:23] thesubr00t: Hi everybody, can someone please help me solve this quiz
[14:17:44] thesubr00t: Hi everybody, can someone please help me solve this quiz
[14:18:35] thesubr00t: has joined #RubyOnRails
[14:19:57] thesubr00t: This may not be rails related, but I'm having some difficulty solving this quiz:
[14:20:06] thesubr00t: Any help will be appreciated
[14:24:27] thesubr00t: dminuoso, sevenseacat, yes it is. I'm doing well so far but I think it's missing some cases. The big issue is how to calculate the total possible route when a rider is delivering more than one order
[14:26:23] thesubr00t: He is not a ruby/rails developer. He got the quiz from a friend ..
[14:28:19] thesubr00t: ljarvis, this is my actual code
[14:29:13] thesubr00t: I think there is some case missing, example for example when rider is delivering multiple orders, how to calculate the route time correctly
[14:31:04] thesubr00t: sevenseacat, dminuoso, As I said I am 80% done with all cases :)
[14:31:11] thesubr00t: But I got your points
[14:33:28] thesubr00t: sevenseacat, here is my code so far
[14:36:56] thesubr00t: mauro1254, I think you should respond with a json representation for all http errors, specially if you are following the JSONAPI specs
[14:37:07] thesubr00t: sevenseacat, my bad :)
[14:38:41] thesubr00t: You have to rescue each type of them individually
[14:58:28] thesubr00t: mauro1254, Yes that a way to do it
[16:54:17] thesubr00t: Quit: Ex-Chat


[17:53:01] thesubr00t: has joined #RubyOnRails
[17:54:27] thesubr00t: How can I sort an array of object by calling an instance method on each element?
[17:57:06] thesubr00t: tbuehlmann, thanks!
[18:31:16] thesubr00t: baweaver, this bit of code must be done using ruby no db side.. here is the snippet I want to re-factor
[18:36:18] thesubr00t: baweaver, the data are collected from a third party API :)
[20:46:15] thesubr00t: Remote host closed the connection


[13:24:17] thesubr00t: has joined #RubyOnRails
[13:25:02] thesubr00t: Is anyone experiencing duplicate nested records upon CREATION with ActiveAdmin?
[14:26:36] thesubr00t: Why is ActiveAdmin creating duplicate attributes for nested models? (only in create action, edit works fine)
[14:27:08] thesubr00t: duplicate records*
[14:45:39] thesubr00t: Quit: Leaving


[13:12:39] thesubr00t: has joined #RubyOnRails
[13:14:02] thesubr00t: I have an app in production andI want to change all my tables primary_key to uuid. How can I achieve this without losing any data?
[13:15:04] thesubr00t: I already enabled postgreSQL extension & set application generator to use uuid for future tables. How can I change the old tables?
[13:16:08] thesubr00t: sevenseacat, Is it that hard? :D
[13:17:25] thesubr00t: sevenseacat, It's easy to start using uuid for primary_keys, my only concern is about my old tables/data
[13:28:07] thesubr00t: pontiki_, sure! I am looking for some best practices and advices
[13:30:06] thesubr00t: pontiki_, I'll do that. Thank you :)
[13:35:13] thesubr00t: pontiki_, True. I think that will be complicated because I am using jsonapi-resource to serve my API, and it insist that the ORM uses the uuid as default if I need to change the finder key
[13:36:10] thesubr00t: pontiki_, That's why I think to change the id type to uuid
[13:39:43] thesubr00t: pontiki_, Thank you for your suggestions, they are helpful :)
[15:10:30] thesubr00t: Ping timeout: 244 seconds
[15:11:04] thesubr00t: has joined #RubyOnRails
[15:47:06] thesubr00t: Quit: Leaving


[21:43:05] thesubr00t: has joined #RubyOnRails
[21:46:33] thesubr00t: I have an application that uses Devise omniauthable with facebook & twitter, since twitter does not provide the user email in the auth hash, how to fetchan already created user when autheticating from twitter
[21:46:54] thesubr00t: is there a way?
[21:50:15] thesubr00t: mikecmpbll,provider & uid are different for each authorization
[21:50:50] thesubr00t: mikecmpbll, uid from twitter is not the same uid from facebook
[21:54:27] thesubr00t: mikecmpbll, Thats true. When I first authenticate with facebook than I signout, then autheticate with twitter, it will be a whole new user
[21:54:35] thesubr00t: mikecmpbll, check this line
[21:55:10] thesubr00t: mikecmpbll, twitter does not give emails
[21:59:31] thesubr00t: mikecmpbll, yeah! devise rely on the email which twitter doesn't provide for oauth
[22:00:50] thesubr00t: mikecmpbll, I couldn't find another way since I'm using Devise
[22:02:22] thesubr00t: mikecmpbll, I'm using them too, the problem remains
[22:06:42] thesubr00t: user has_many authorization, if a user signup using facebook first, he will have an authorization with provider: "facebook" & uid: "some_uid_from_facebook". Now if he logout then signin using twitter he will have another authorization with provider: "twitter" & uid: "some_uid_from_twitter". when with facebook he will have email, when with twitter there is no email. thats why the problem remains
[22:07:35] thesubr00t: mikecmpbll, make sense?
[22:08:25] thesubr00t: mikecmpbll, yep
[22:11:00] thesubr00t: mikecmpbll, I already did that, and it works perfectly. My problem now is when logging from facebook then logout & login with google-plus from example devise finds the user created from facebook, but in case of twitter it will create a whole new user.
[22:12:47] thesubr00t: mikecmpbll, the user does not have an authorization from twitter unless he first login with it.
[22:16:23] thesubr00t: mikecmpbll, Yes, that's what I'm looking for :)
[22:16:54] thesubr00t: mikecmpbll, otherwise that workflow s right
[22:17:49] thesubr00t: mikecmpbll, here is what you get from twitter
[22:20:46] thesubr00t: mikecmpbll, yes that way they can hijack others acoounts
[22:26:00] thesubr00t: matthewd, Can you please elaborate?
[22:26:38] thesubr00t: matthewd, I mean a mechanism like what?
[22:28:01] thesubr00t: matthewd, Looks like a solution. I'm going to test it. Thanks for the suggestion!
[23:33:28] thesubr00t: Ping timeout: 264 seconds


[16:11:01] thesubr00t: has joined #RubyOnRails
[16:13:31] thesubr00t: What is the best way to query current_user.posts + current_user.blogs.find([1, 2, 5]).posts ?
[16:14:54] thesubr00t: more specifically current_user.posts.find(array_of_ids) + current_user.blogs.find(array_of_ids).posts
[16:15:18] thesubr00t: tubbo, I want to get an array of uniq posts from the two queries
[16:15:59] thesubr00t: Is there a way to get it from one AR query?
[16:16:50] thesubr00t: User has_many :posts, has_many :blogs and Blog has_many :posts
[16:17:32] thesubr00t: tubbo, wait I'll post a gist
[16:21:01] thesubr00t: tubbo,
[16:21:41] thesubr00t: posts/blogs associations are with a joing table
[16:23:52] thesubr00t: tubbo, you get the idea?
[16:26:26] thesubr00t: smathy, the name of Models are just examples
[16:28:50] thesubr00t: smathy, helpa sorry, I wasn't aware of such rule. no NDA though :)
[16:33:18] thesubr00t: smathy, tubbo, here is what I tried so far
[16:37:25] thesubr00t: tubbo, one sec
[16:41:25] thesubr00t: tubbo, it gives an error of undefined social_accounts for Array
[16:41:49] thesubr00t: tubbo, current_user.channels.find(channel_ids).social_accounts
[16:46:02] thesubr00t: tubbo, Why you asked for that sql?
[17:23:30] thesubr00t: Quit: Leaving


[10:33:54] thesubr00t: has joined #RubyOnRails
[10:44:58] thesubr00t: What is the proper way to validate that the associated objects (has_many) are owned by current_user?
[10:45:48] thesubr00t: I want to validate that social_accounts are owned by current_user when associating them to current_user.grouped_social_accounts
[10:50:51] thesubr00t: So quite here :-)
[10:51:23] thesubr00t: Where are the good folks?
[10:54:25] thesubr00t: alfie_max15, can you please look at my question?
[10:57:32] thesubr00t: n_e_o, alfie_max15: a user may select a signle social_account or a list of them (grouped).
[11:00:40] thesubr00t: n_e_o, I want to be able to use `current_user.social_accounts` wich will iterate on all of them, and `current_user.grouped_social_accounts` to iterate on the limited set of social accounts.
[11:03:47] thesubr00t: eg: current_user.social_accounts => [{x}, {y}, {z}], currentuser.grouped_social_accounts => [{name, [{x}, {y}]}, {name, [{x}, {z}]}]
[11:05:44] thesubr00t: I(ve updated the gist
[11:07:01] thesubr00t: n_e_o, alfie_max15 channels are optionals
[11:07:12] thesubr00t: alfie_max15, sorry thats only on the gist lol
[11:11:37] thesubr00t: alfie_max15, does it make sense?
[11:12:22] thesubr00t: think of it like facebook messages & groups messages
[11:15:15] thesubr00t: I may use join table for that
[11:15:21] thesubr00t: many to many
[11:15:31] thesubr00t: thank you for the hint
[11:16:05] thesubr00t: but the problem of validations still exists
[11:16:28] thesubr00t: I want to validate that current_user may nly group his own social_accounts
[11:17:05] thesubr00t: there is no "builtin" validator for that?
[11:17:34] thesubr00t: ok, thank you!
[11:33:19] thesubr00t: axilla, The simplest way I can think of is that products have a `approved` boolean attribute with default to false.
[11:35:13] thesubr00t: Then it's up to you to flag it as approved bu updating that attribute to true
[12:22:11] thesubr00t: baash05, check the postgres role permissions
[12:53:23] thesubr00t: Read error: Connection reset by peer
[13:50:21] thesubr00t: has joined #RubyOnRails
[16:36:30] thesubr00t: Quit: Leaving


[22:20:05] thesubr00t: has joined #RubyOnRails
[22:21:32] thesubr00t: Is there a way to validate a has_many association to limit them to the current_user associated records?
[22:29:04] thesubr00t: Quit: Page closed