Arkentias

Activity Graph

Page 1 of 2 | Next »

2019-04-03

[14:34:42] Arkentias: has joined #ruby
[14:36:32] Arkentias: Hello guys! Given a multi-dimensional JSON object, I would want to get the list of all the "dead-end" attributes in dot notation. A dead-end attribute being one that is not an object or array (only objects in my case).
[14:36:52] Arkentias: So for example this : { "breadcrumb": { "accueil": "Home" }, "donate_form_block": { "type_text": "Text" } }
[14:37:13] Arkentias: Would just give me : ["breadcrumb.accueil","donate_form_block.type_text"]
[14:37:35] Arkentias: (Sorry I meant dead-end attribute's KEYS)
[14:39:39] Arkentias: It can't be that hard but I wonder if there is a "clean" way to do that and avoid manually looping over everything
[14:42:29] Arkentias: I guess I'll just make a recursive function
[14:45:22] Arkentias: Thanks! I'll look into that then :)
[15:02:13] Arkentias: Remote host closed the connection

2019-02-27

[13:22:16] Arkentias: has joined #RubyOnRails
[13:24:58] Arkentias: Hello ! I have a probably very stupid question but I can't find the answer on Google as surprising as it is. I simply want to find a record and get one of its association with it so that I can just render it right away (It's a show action on a record). How would I do that?
[13:26:33] Arkentias: Ok so there is no way to do this in one query?
[13:26:42] Arkentias: Maybe with a "where" then?
[13:29:59] Arkentias: Ok so my Transaction model belongs_to a "Procedure" model. I have a endpoint "GET /transaction/:id" to retrieve the informations of that transaction AND have the information on the procedure in transaction.procedure. So I want my transaction instance to have it's "procedure" field already filled with the procedure informations when I render it in JSON so that it can be retrieved from the API response
[13:31:47] Arkentias: The transaction : {"id": 123, "transaction_name": "a transaction", "procedure": {"id": 23, "procedure_name": "a procedure"}}
[13:32:37] Arkentias: Yes it sure does sound ultra easy but how can I do that in one line? I tried includes, joins, .. and nothing yields the expected result
[13:32:59] Arkentias: Maybe I HAVE to use a serializer to reach the expected result?
[13:34:50] Arkentias: Right now I just use the "render json: " because the app is still in the building phase
[13:35:13] Arkentias: But I have generalized "respond_ok", "respond_unprocessable" methods etc in my application_controller
[13:35:30] Arkentias: So in my transactionsController I just do "respond_ok @transaction"
[13:36:09] Arkentias: So i'd like to be able to do "respond_ok @transaction.with(:procedure)" or something?
[13:49:30] Arkentias: Ok thanks a lot! SO I have to do this at serialization time :) I'll just work on my serializer then ! Thank you for taking the time to help me
[15:36:50] Arkentias: Quit: Leaving

2019-01-11

[10:17:24] Arkentias: has joined #RubyOnRails
[10:19:03] Arkentias: Hey guys! I have a resource with a nested route like so resources :procedures do
[10:19:04] Arkentias: post :execute
[10:19:17] Arkentias: (new line after "like so")
[10:19:39] Arkentias: I want to be able to do a post on a specific procedure, hence the "post :execute"
[10:20:12] Arkentias: The problem is that for all the routes of the resource, the id params is called :id, but for "post :execute", it's called :procedure_id
[10:20:48] Arkentias: I know this is the normal behaviour but I'd like to be able to use the same "set_procedure" method for both use cases in my controller, any idea? Should I just check for the existence of :id & :procedure_id ?
[10:29:06] Arkentias: tbuehlmann Thanks a lot! Looks perfect now :)
[10:37:26] Arkentias: Spaceman77 I think a lot of people would be happy to help you but you're not really giving any information regarding your problem
[10:37:31] Arkentias: Quit: Leaving
[13:14:00] Arkentias: has joined #RubyOnRails
[13:16:30] Arkentias: Hey again guys, I have this in my model's initialize method but everytime I try to accept my @ variable in my instance methods, it's nil. Any insight?
[13:16:31] Arkentias: def initialize(options = nil)
[13:16:32] Arkentias: @model_errors = []
[13:16:32] Arkentias: super(options)
[13:17:38] Arkentias: I'm supposed to be able to access @model_errors in all my instance methods right?
[13:26:03] Arkentias: Ah oups not me
[13:27:25] Arkentias: Yes but in fact "model_errors" is an array in which I put errors from other models that i'm validating, weird use case but those are errors from elsewhere
[13:29:41] Arkentias: No they are not especially. Long story short this object receives a big payload describing objects to create that can be any of the Models in my application. It validates them and returns the array of errors if there is a single one, if not it will persist them all to the DB
[13:30:26] Arkentias: The business logic is pretty intricate but I'm just trying to find out why those hecking instance variables are nil even from the class itself
[13:31:37] Arkentias: I'm doing Object.find then calling Object.do_something and the @ variables are nul in the do_something method. Initialize is called everytime you instantiate an object right?
[13:38:44] Arkentias: OK turns out initialize isn't called everytime an object is instantiated in fact
[13:39:11] Arkentias: Used after_initialize callback instead!
[13:40:03] Arkentias: Ah yeah works too indeed!
[13:41:19] Arkentias: Thanks for your assistance!
[13:44:41] Arkentias: Looks like @member is an array, maybe you meant it to be a instance of User?
[13:45:04] Arkentias: Have a look at how you declare @member
[13:47:38] Arkentias: Yeah look at the definition of "from_auth" in Member and fiddle around in "rails c" as tbuehlmann says
[13:51:16] Arkentias: OK then keep on digging, look at locate_auth and locate_email, put some logs here and there, ..
[13:51:47] Arkentias: locate_auth, locate_email and create_from_auth one by one to make sure they all return a Member object
[13:51:56] Arkentias: *try locate_auth, ..
[13:52:24] Arkentias: (create_from_auth seems good but what about the other ones?)
[13:52:35] Arkentias: Also make sure @member is not declared in multiple spots
[13:56:33] Arkentias: You're calling "Member.from_auth" but the "from_auth" method call you sent me declares it as an instance variable, that's pretty weird
[13:58:17] Arkentias: I think you meant to declare "def self.from_auth" for example
[14:04:19] Arkentias: I can't really find anything compelling honestly. It does feel like one of the methods or attribute is a reserved name or something
[14:05:52] Arkentias: What I would do is put some logging in every method of the stack to make sure the right one is called..
[14:06:00] Arkentias: Dirty but would probably do the job
[14:06:20] Arkentias: There are probably smarter ways to do it though
[14:08:48] Arkentias: Good luck! Sorry I can't help more
[14:24:23] Arkentias: Quit: Leaving

2018-11-22

[09:41:19] Arkentias: has joined #RubyOnRails
[09:44:49] Arkentias: Hey guys! I'm looking for nice ways to serialize objects in my Rails 5 API. I have methods defined for every kind of API responses in my application_controller (respond_ok, respond_forbidden) etc. I'd like the serialization to happen in the controller, before sending the data to "respond_ok". AMS doesn't seem to suite my need since it should be passed to the render method
[09:50:24] Arkentias: I guess I just want to override the to_json method and maybe accept a variable to allow for different levels of serialization per model. I was wondering if maybe something exists by default to do that? Or a nice library?
[10:40:48] Arkentias: Quit: Leaving

2018-11-02

[09:06:46] Arkentias: has joined #RubyOnRails
[09:09:12] Arkentias: Hey everybody! I'm currently customizing the look of my error messages. I'm looking for a way to apply the "underscore" method to the attributes in the error, or even the whole error. How would I do that? I tried putting it directly in the translation YAML but of course it doesn't work
[09:14:23] Arkentias: In short I want this : "errors: format: "%{attribute} %{message}"" to become this: "errors: format: "%{attribute.underscore}_%{message}"" or this : "errors: format: "%{attribute} %{message}".underscore"
[09:14:28] Arkentias: Is there a clean way to do that?
[09:40:00] Arkentias: Okay, I got to the result I wanted by declaring self.human_attribute_name on my model, is there a way I could declare this to all my Models without copy-pasting in each one of them?
[15:45:16] Arkentias: Quit: Leaving

2018-10-19

[09:06:07] Arkentias: has joined #RubyOnRails
[09:09:46] Arkentias: Hello! I have a very basic question. All my Users belong to a Client. The email is unique per client. I want to retrieve all the Clients that have a user with an email address X. Do I just do User.where(email: x).joins(:client).select('clients.*') or something in that idea? (or use pluck I guess)
[13:27:22] Arkentias: Quit: Leaving

2018-10-03

[12:50:15] Arkentias: has joined #RubyOnRails
[12:53:57] Arkentias: Hey everybody! I'm looking for a nice way to handle image uploads to S3 with different sizes per image everytime. I think ActiveStorage might have been an ~OK fit but some of the fields that need to contain those images are elements of a JSONB attribute. I'm under the impression that ActiveStorage needs some root model relations to function correctly
[12:54:19] Arkentias: Am I right? Would I be better off just writing my own solution since it's not THAT hard to do?
[13:01:47] Arkentias: Thanks for the answer
[13:02:05] Arkentias: The "has_image" thingie is not related to an attribute at all in fact? it's just an arbitrary name?
[13:02:32] Arkentias: I mean an attribute from the database
[13:04:14] Arkentias: OK yeah but the DB attribute will be in the tables that active storage creates, not in my model's schema I guess
[13:04:30] Arkentias: No problem! I think i'll figure things out myself :) Thanks for the help!
[13:04:43] Arkentias: You pointed me in the right direction
[13:20:25] Arkentias: I don't know a lot about this but maybe this could help https://github.com/mperham/sidekiq/wiki/Advanced-Options#connection-pooling
[13:29:15] Arkentias: Auto::Brand needs to have an "has_many :models" association
[13:29:34] Arkentias: @logik-bomb
[13:30:55] Arkentias: In your AutoModels migration you can also simply write "t.belongs_to :brand, index: true" instead of using references but I think ereferences works too
[13:35:30] Arkentias: Happy to help!
[14:05:39] Arkentias: Quit: Leaving

2018-08-20

[09:06:12] Arkentias: has joined #RubyOnRails
[09:06:49] Arkentias: Hey guys! Do any of you know of a simple way to use all my JSONB attributes as an OpenStruct structure? Like navigating it with dots instead of Hash syntax?
[14:03:19] Arkentias: Thanks Radar, just saw your answer :p I'll look for a way for that to be automatic everytime I fetch a record from the DB
[15:27:40] Arkentias: Quit: Leaving

2018-08-17

[15:03:57] Arkentias: has joined #RubyOnRails
[15:04:45] Arkentias: Hey! Do any of you know if there is any clean way to use my JSONB fields as OpenStruct (all of them)
[15:12:45] Arkentias: It's not compatible because one does a join and not the other one
[15:13:12] Arkentias: You don't select the same fields in both queryies
[15:15:45] Arkentias: What if you force a select on the first a.where?
[15:16:13] Arkentias: Unless you actually need to select the relation also, but if you don't then it might do the trick?
[15:18:08] Arkentias: Same error?
[15:20:10] Arkentias: Well in SQL it's clearly an union no?
[15:37:27] Arkentias: <jeromelanteri> you can be read
[15:37:45] Arkentias: Just that no one is inspired I guess :p
[15:37:50] Arkentias: Quit: Leaving

2018-08-03

[09:46:07] Arkentias: has joined #RubyOnRails
[09:47:48] Arkentias: Hey guys! I have a small question, let's say I have an instance of an active record model with some dirty instance variables, is there a way to get another instance of this exact same model but with clean instance variables?
[09:48:27] Arkentias: Well get another instance of the same record from the DB, without calling the DB, and without having the dirty instance variables
[09:51:14] Arkentias: I guess I just .clone it and clean the variables by hand?
[09:51:59] Arkentias: Mmmh but those instance variables are in fact cleaned in the initialize method so there is probably a better way
[10:13:18] Arkentias: Well let's dump it down, I have an instance of an object, i want the same instance but initialized & without calling the db
[11:24:50] Arkentias: Ping timeout: 260 seconds

2018-07-24

[07:00:49] Arkentias: has joined #RubyOnRails
[07:03:49] Arkentias: Hello ! I have a question, do you guys think there is a way for me to store lambdas in the database somehow?
[07:04:48] Arkentias: Yes I know that it seems crazy and stupid but in a world where this would be a good idea, how would one do that?
[07:05:23] Arkentias: If it's even possible
[07:06:37] Arkentias: ahaha no I know
[07:06:40] Arkentias: I'll give a bit of background
[07:06:57] Arkentias: No no of course not user entered code
[07:07:06] Arkentias: That's actually something we do in our V1... Crazy..
[07:07:17] Arkentias: (I didn't write the code)
[07:08:04] Arkentias: Ok so we provide a product that allows for easy creation of fundraising platforms for NGOs, the idea is that users create 'projects' through which they raise money for the NGO by asking their families and friends etc
[07:08:38] Arkentias: But this expanded, sometimes you just "vote" for a project, sometimes you give money, sometimes you buy products, sometimes you buy a ticket, etc
[07:09:10] Arkentias: And this action can now be applied on a platform directly (root level), on a group of project, or on a project (or even a user)
[07:09:47] Arkentias: So my idea is to try to have a 'recipe' for the funnel that users go through when they want to do one of these actions
[07:10:09] Arkentias: This recipe would be my "Procedure" object, which already contains a JSON that allows for easy changing of the form that user go through
[07:11:02] Arkentias: And I'm trying to find a way to maybe have some sort of recipe in the backend for the different records to create etc depending on the Procedure, like one would create a Vote, one would create a transaction + make the User follow a project etc
[07:12:11] Arkentias: But indeed, the client would have to be able to play around with it through our Backoffice, so I can't just let our Vue application send Ruby code, that's a no go, absolutely
[07:12:45] Arkentias: Just trying to figure out how to attain a high level of flexibility without shooting my own foot
[07:14:12] Arkentias: Yeah I guess it makes sense for that model to be really fat
[07:14:22] Arkentias: Since it's basically all of our application
[07:17:52] Arkentias: Ahaha ok I guess it's indeed better that way, when we need more behaviour i'll just add some methods
[07:17:56] Arkentias: Thanks for the help guys!
[09:13:54] Arkentias: Used to, a long time ago, might be able to help
[09:15:58] Arkentias: Are you sure you're using the right callback to save to the database?
[09:19:48] Arkentias: Did you check in the Google Dev Tools when your updates are sent to the Rails API?
[09:20:12] Arkentias: Is the update really sent when you drop the thingie?
[09:20:27] Arkentias: VS not when you start dragging
[09:21:02] Arkentias: Ok, try using the "Network" tab
[09:21:14] Arkentias: It is your main tool when dealing with SPAs and APIs
[09:21:42] Arkentias: It shows you exactly the requests sent
[09:23:43] Arkentias: Ok so you are certain that the update happens everytime you DROP something?
[09:23:52] Arkentias: Even the first time? Or the update is not sent at all ?
[09:25:25] Arkentias: I think it updates the whole list everytime, not move per move, so the first "Dropped" event is apparently not handled but the rest is so when the second "dropped" event happens, the whole list is saved to the DB
[09:26:07] Arkentias: So the idea is to find why that first even is not handled. When you put a console.log in the "dropped" handler, the function doesn't even get called the first time, right?
[09:27:33] Arkentias: You're now certain that the problem is in Angular
[09:27:58] Arkentias: You will probably have to check the code that triggers the "dropped" event
[09:29:11] Arkentias: ... I know that feel, and I can see that looking at his Rails controller. Good luck with that project
[09:31:09] Arkentias: The problem here is not the data guys, the problem is the AngularJS event not even being triggered, that's the first thing to fix before even thinking about the rest I think
[09:31:30] Arkentias: Maybe the data will be a problem after that, but if the request is not even sent to Rails, that should be fixed first
[09:32:19] Arkentias: That's not what Charlie is saying, the event is not triggered on the first move
[09:33:15] Arkentias: @Charliebr73, you did observe in the Network tab that the request wasn't send on the first move, right?
[09:34:01] Arkentias: Then if the request is not sent, the problem lies in Angular
[09:34:14] Arkentias: don't you think sevenseacat?
[09:34:57] Arkentias: I mean at least the first problem to solve is that one
[09:35:02] Arkentias: Good luckè
[09:43:44] Arkentias: Try using the dragStop event to see if the behaviour changes @Charliebr73
[09:56:02] Arkentias: Everything looks fine in the gist indeed
[09:56:51] Arkentias: Wait you get an error in the show view but the manage_room_path is in the index view?
[10:01:57] Arkentias: yes but the error in the gist says buildings/show.html.erb where line #29 raised: blablbal
[10:06:25] Arkentias: I don't think so no but that's the only weird thing I could find in the gist :p
[10:06:52] Arkentias: I don't think I would be able to help with those informations but maybe someone else has an idea or has already encountered a similar issue
[10:07:41] Arkentias: And you managed to find something in there?
[10:10:25] Arkentias: Indeed this is bit the same as in the documentation, I'm not well versed enough in Rails to tell you why though. Are you using Rails 5?
[10:12:02] Arkentias: It is weird to me that you don't have an index route or anything, maybe someone else has an idea on that? Because I don't :p
[10:58:19] Arkentias: Damn and here I was thinking resources was when you declared multiple resources at once, when I myself use both singular and plural resoruces in my application.. Dumb me, glad you found the issue
[12:45:38] Arkentias: Quit: Leaving

2018-06-18

[09:35:22] Arkentias: has joined #RubyOnRails
[09:37:45] Arkentias: Hey everyone!I need your help. For every request that hits my API, i need to check the url it came from to be able to know which of my client's data I should access. Where should I put this kind of logic that should happen once for every request?
[09:43:18] Arkentias: Read error: Connection reset by peer

2018-05-24

[08:00:20] Arkentias: has joined #RubyOnRails
[08:04:51] Arkentias: Hello everybody! I was wondering if some of you might be able to suggest some gems that might help me out. I have to implement a "per resource" RBAC. Example : the same user account can be admin of a group, but simple user of another group, and moderator of yet another one. I find a lot of gems meant to provide an "application-wide" role but I have trouble finding more granular ones
[11:16:39] Arkentias: Remote host closed the connection
[12:11:56] Arkentias: has joined #RubyOnRails
[12:43:22] Arkentias: Well full command will be "rails g" + your generator + args + options, right?
[12:44:12] Arkentias: Which of these don't you have?
[12:48:40] Arkentias: Check this out for options http://guides.rubyonrails.org/generators.html#adding-command-line-arguments
[12:49:00] Arkentias: Arguments should be declared in your generator class, so you can just access them by their name
[12:50:03] Arkentias: You can select the one you need: options['your_option']
[12:51:48] Arkentias: Ok I think I might not be knowledgeable enough to help you then, i'm sorry
[12:56:20] Arkentias: Rails generator are built using "Thor" I think so you might find some good informations there
[13:15:45] Arkentias: Great good luck!
[13:33:55] Arkentias: Remote host closed the connection

2018-04-20

[15:23:45] Arkentias: has joined #RubyOnRails
[15:40:30] Arkentias: Quit: Leaving

2018-02-21

[15:40:10] Arkentias: has joined #RubyOnRails
[16:19:26] Arkentias: Quit: Leaving

2018-01-24

[12:39:20] Arkentias: has joined #RubyOnRails
[14:06:35] Arkentias: Quit: Leaving

2018-01-02

[14:13:57] Arkentias: has joined #RubyOnRails
[14:39:45] Arkentias: Quit: Leaving

2017-11-29

[09:47:36] Arkentias: has joined #RubyOnRails
[14:12:06] Arkentias: Quit: Leaving

2017-11-23

[14:42:59] Arkentias: has joined #RubyOnRails
[15:04:00] Arkentias: Ping timeout: 248 seconds
[15:19:55] Arkentias: has joined #RubyOnRails
[16:37:34] Arkentias: Quit: Leaving

2017-09-26

[13:54:07] Arkentias: has joined #RubyOnRails
[15:37:46] Arkentias: Quit: Leaving

2017-09-25

[08:30:04] Arkentias: has joined #RubyOnRails
[08:55:00] Arkentias: Quit: Leaving

2017-09-12

[07:19:46] Arkentias: has joined #RubyOnRails
[14:42:06] Arkentias: Quit: Leaving

2017-09-08

[09:46:09] Arkentias: has joined #RubyOnRails
[14:40:43] Arkentias: Quit: Leaving

2017-08-30

[07:12:59] Arkentias: has joined #RubyOnRails
[08:32:59] Arkentias: Quit: Leaving

2017-08-24

[07:32:47] Arkentias: has joined #RubyOnRails
[08:21:38] Arkentias: Quit: Leaving

2017-07-31

[09:07:08] Arkentias: has joined #RubyOnRails
[10:38:16] Arkentias: Ping timeout: 240 seconds
[10:51:29] Arkentias: has joined #RubyOnRails
[13:47:56] Arkentias: Quit: Leaving

2017-07-28

[09:33:55] Arkentias: has joined #RubyOnRails
[14:38:56] Arkentias: Ping timeout: 246 seconds
[14:51:37] Arkentias: has joined #RubyOnRails
[15:04:19] Arkentias: Ping timeout: 240 seconds
[15:16:39] Arkentias: has joined #RubyOnRails
[15:22:34] Arkentias: Quit: Leaving

2017-06-29

[11:53:46] Arkentias: has joined #RubyOnRails
[11:54:36] Arkentias: Client Quit
[11:54:55] Arkentias: has joined #RubyOnRails
[13:17:12] Arkentias: Quit: Leaving

2017-06-14

[13:18:06] Arkentias: has joined #RubyOnRails
[15:42:13] Arkentias: Quit: Leaving

2017-06-12

[08:41:14] Arkentias: has joined #RubyOnRails
[09:21:20] Arkentias: Quit: Leaving

2017-06-09

[07:39:09] Arkentias: has joined #RubyOnRails
[07:39:39] Arkentias: Client Quit

2017-05-11

[07:31:52] Arkentias: has joined #RubyOnRails
[08:45:21] Arkentias: Quit: Leaving

2017-04-27

[07:33:08] Arkentias: has joined #RubyOnRails
[10:25:48] Arkentias: Quit: Leaving

2017-04-26

[08:13:04] Arkentias: has joined #RubyOnRails
[12:20:37] Arkentias: Quit: Leaving