#RubyOnRails - 17 October 2018
Forward 1 day »
[02:37:23] Yzguy: so I've stumbled upon a legacy app doing a lot of as_json overrides in models for API routes
[02:37:56] Yzguy: which is super painful, because the API output is very different than what you would POST/PUT to create/update things
[02:39:01] Yzguy: I've been reading about serializers, but all the examples I find reference using them in the index/show actions. Which makes sense to me. The question I have is that, would you/could you post back the structure you get from the index/show to an edit action and it would work?
[02:40:20] Yzguy: like if I had a Device, and it has some attributes, but it also has a ports attribute that is an array of port objects
[02:46:33] Yzguy: eh I think I could do a quick small thing to test and make my understanding better
[03:21:32] MrCrackPotBuilde: Hi im getting a little confused wondering if someone could just confirm my thought process. As i understand devise is just a framework you can use for handling users. Its controllers handle the flow of data between the view and model. When a user registers / sign_up the registration controller is used. When a user logs in the sessions controller is used and so on and so forth for the remaining controllers. Each controller is not needed as
[03:21:32] MrCrackPotBuilde: devise auto configures them for you as is the rails way. However you can create them and override the functions. With an API we dont need sessions insteads tokens. I have been looking at https://scotch.io/tutorials/build-a-restful-json-api-with-rails-5-part-two#toc-authorize-api-request which doesnt use devise but should be very simple to add it. It uses an authorizeAPI class to check all requests going into the application. Checking that
[03:21:33] MrCrackPotBuilde: the headers are correct. This im guessing would remain the same as it isnt really to do with devise as such and more security for the API in general. The authenticateUser isnt a controller its a class with a entry point called call. Which encodes a JSON web token. with devise you would use authenticatable_salt not authenticate. Then you have the authenticatenController this i think would be the devise sessions controller. Should i just
[03:21:38] MrCrackPotBuilde: place that inside sessions or skip the sessions controller as its api and route instead to authenticationcontroller
[03:23:27] MrCrackPotBuilde: looking at rails routes with devise_for :users you can see signup signin etc so that also helps to find the corrisponding controller
[03:51:43] Yzguy: eg I'm thinking I want my url to be like /devices/1/ports, and it would give me a list of all the Port objects with the device_id of 1, which I have working. I'm confused on how POST/PUT would work to create/update
[04:04:59] Vashy: e.g. I'm trying to create an edit view for a model (Property) that has_many of another model (PropertyDocument) and each of those has_one_attached document
[04:05:35] Vashy: but whenever I go to the edit view of that Property, and hit save, it creates another attachment that's a copy of the existing document
[04:06:15] MrCrackPotBuilde: Yzguy it should be the same just the link in a different order match the route you want. you also need to define it in routes
[04:10:41] samort7: Big night tonight. Finally finished Hartl's Ruby on Rails tutorial. Got a working Twitter clone :-D
[04:15:33] samort7: Yea, I've been trying to come up with something I actually want/need and have blanking out somewhat. What were some of the first things you built when you were learning Rails?
[04:19:11] samort7: I was legit discussing with my mother today the possibility of me making a site for her
[04:21:34] samort7: no biggie. Was an online education company. 100% remote and only has 4 employees
[04:21:47] samort7: I'm thinking I might need a little more structure since I'm still pretty new to software dv
[04:23:11] samort7: yea. I originally was learning Spring, but gave it up after a bit. I feel like I have a waaay better understanding of MVC after the Rails Tutorial than I did in the months I was learning SPring
[06:21:46] happygilmoregent: I am having issues with connecting angular and rails and need some guidance
[06:24:04] happygilmoregent: no errors with webpack compiles successfully but it doesn't convert the angular tag <shine-customer-app> to a router-outlet
[06:54:57] syndikate: When sorting with ransack if the field values are all same ransack does not sort the entire table - how does ransack manage to do that?
[06:56:00] syndikate: My assumption was this - even if the specific column values are all same, the table should get sorted desc and ask alternatively. Is it because the SQL query returns the rows without difference?
[07:19:59] ss942: I can't call function from my helper inside partial... I included it in controller, and it works in index.html.erb
[07:27:53] ss942: https://github.com/lapinskik/redmine_wktime/blob/master/app/controllers/wkaccount_controller.rb <- controller
[07:27:53] ss942: https://github.com/lapinskik/redmine_wktime/blob/master/app/helpers/wkcustomfields_helper.rb <- this is the helper
[07:27:53] ss942: https://github.com/lapinskik/redmine_wktime/blob/master/app/views/wkaccount/edit.html.erb <- I render partial there
[07:27:53] ss942: https://github.com/lapinskik/redmine_wktime/blob/master/app/views/wkcustomfields/_relations.html.erb <- this is the partial
[07:30:13] ss942: and method that returns "method or variable not found" is options_for_project_select in 12 line of relations partial
[07:32:02] ss942: >ActionView::Template::Error (undefined local variable or method `options_for_projects_select' for #<#<Class:0x00000000067ae0a8>:0x00007f78b581e540>
[07:40:20] ss942: I just don't know why I can't access options_for_project_select I included it in wkaccount_controller, but _relations.html.erb dosen't allow me to see it.
[07:47:31] sevenseacat: https://stackoverflow.com/questions/17299484/redmine-plugin-development-helper-method-not-found-in-view ?
[12:13:13] Pupeno_: I'm building an application that will have many complex evolving email workflows. Are there any tools out there that can host and/or help build those emails?
[13:49:10] bothari: Hello. I'm learning rails, I'm curious about editing and forms. I have an event object that has many tasks. When creating or editing the event, I want to be able to add/remove/edit the tasks, too.
[13:49:55] bothari: I've heard about partials, and I think that's the right approach, but I'm looking for a good tutorial. Any ideas?
[13:57:54] tbuehlmann: bothari: you can read up on accepts_nested_attributes and fields_for, that's for creating/updating a record and its children using one form. dynamically adding/removing tasks using js is not really supported in rails itself, but there's the cocoon library, which will help doing exactly that