#RubyOnRails - 01 May 2016
« Back 1 day Forward 1 day »
[00:20:22] hnanon: I want to create the first user when creating the company so I have accepts_nested_attributes_for :user.
[01:08:33] jeffleeismyhero: I’m trying to create a regex for the following text: "Engine-6 Cyl-Straight, Engine-Turbocharged"
[01:08:50] jeffleeismyhero: I need to strip out "Engine-" from the text. However, "Engine-" could also be "Another String-"
[01:27:00] Eaven: Hello. I am trying to run a where query in rails 4.2 and when I run DateTime.current I am given "Sat, 30 Apr 2016 18:22:55 -0700" which is correct.. but when I use DateTime.current the query is being given Post Load (0.3ms) SELECT `posts`.* FROM `posts` WHERE (`posts`.`post_at` BETWEEN '2016-05-01 01:22:51' AND '2016-05-01 01:17:51')
[01:27:03] Eaven: I'm not sure why it's searching for tomorrows records when it outputs todays date when I test DateTime.current
[01:27:25] jeffleeismyhero: I did it upstream before they were joined with the comma and it worked out to be easier.
[01:58:48] billy12: what's the best way to check for duplicates within a specific column in a table via activerecord?
[01:59:33] billy12: if I have a table 'products', and it has a column 'name', I want a conditional statement to see if any of the name values are identical
[02:00:04] billy12: I know how to do it if I build an array of the contents of products.name and then go if myarray.uniq.length == myarray.length
[02:00:24] billy12: but if there's something built in to activerecord that results in less queries or is more optimized that would be great
[02:00:44] billy12: if anyone happens to know please let me know or if someone notices this question later, please msg me, thank you
[02:25:26] roamingdog: i'm thinking if i knew your purpose there'd be a better way to answer, but if the number returned for the statement with 'distinct' is different than the other one, then there's at least one duplicate name
[02:28:21] roamingdog: something like if (select count(*) from products;) <> (select count(distinct(name) from products;) that is
[03:29:54] xcesariox: what kind of attribute do we use to store a picture if we are using paperclip gem
[03:37:14] xcesariox: Radar : i wanna Generate a Model like `rails g model user name:string add_attachment:avatar?
[03:39:50] Radar: xcesariox: I don't know if there's a way to do it like that. Best way to get answers to your question is to read the paperclip docs. They are very thoroughy.
[04:58:12] vedu: xcesariox: that will work. you have to do `rails g model user name:string avatar:attachment`
[04:59:04] vedu: xcesariox: note that the migration will be generated correctly but your fixtures will not. since :avatar is not a column name
[05:30:18] vedu: What are requests with a string query param like `https://someapi.com/resource/122?1462014610` called? Paperclip with S3 uses it, probably for caching
[05:37:17] vedu: roamingdog: I know caching :) I am following HATEOAS for my api but I feel it would be better to provide the updated_at time as well rather than just a link
[05:40:43] vedu: matt_d: haha no no. the `?` threw me off. I thought roamingdog was asking me for some more info
[05:40:43] roamingdog: it's fine, prolly read 'cache...something' and thought, 'oh, i know all about that, i'm so awesome' jk
[07:26:25] vedu: How to use 'path helpers' for routes part of 'dynamic segments'? current code and test failure: https://gist.github.com/vedant1811/a91dbabf1c2b9341494b6af2228ca916
[08:45:09] Spami: I'm having troubles understanding how I can pass with plan the user is subscribing to in the form?
[10:28:50] arup_r: so when using HABTM, say between 2 models User and Group. I see while adding/removing groups to/from users, `updated_at` columns doesn't update. I'm using `#collection_singular_ids=` method to do this. I can touch like, http://stackoverflow.com/a/23923329 . Asking because there might be some naive approach for this?
[11:06:20] RORapprentice: Hello. I have a belongs_to has_many relationship between an user_story and a story_backlog. Upon a met condition, I'd like to delete the relationship between them, such that I want user_story.story_backlog = nil and the user story removed from the story_backlog's collection
[11:07:00] RORapprentice: I looked and found dependent: :nullify, but that means that I need to first remove the user_story, but I do not want to remove it, just the relationship
[11:36:00] roelof: someone who can help me with this problem: https://www.reddit.com/r/rails/comments/4h8bcf/how_do_read_in_nested_directories/
[11:59:55] roelof: someone who can help me with this problem: https://www.reddit.com/r/rails/comments/4h8bcf/how_do_read_in_nested_directories/
[13:07:35] p1k: I'm having some issues identifying the source of a pretty severe memory leak -- I've described it here https://groups.google.com/forum/#!topic/rubyonrails-talk/UL7TUV1Uefk
[13:19:20] roelof: Can anyone help me with this problem ? https://www.reddit.com/r/rails/comments/4h8bcf/how_do_read_in_nested_directories/
[13:48:08] roelof: Can anyone help me with this problem ? https://www.reddit.com/r/rails/comments/4h8bcf/how_do_read_in_nested_directories/ ?
[15:27:33] roelof: someone knows how to make this work : https://www.reddit.com/r/rails/comments/4h8bcf/how_do_read_in_nested_directories/
[15:28:56] mustmodify: I'm trying to push a very-slightly-updated version of a several-year-old Rails app to heroku. The update just has a view that will let us get out the data so we can move it to a new app. But I'm getting "undefined method `empty?' for nil:NilClass". StackOverflow says to check for Gemfile.lock problems. I did update Gemfile.lock to add a gem which, of course, updated some things. But what would I look for in Gemfile.lock to help me get past this?
[15:30:55] roelof: mustmodify: Are you sure that the view uses the right variables. This looks more a problem there then a gem problem
[15:30:56] mustmodify: here are the changes I made. https://gist.github.com/mustmodify/05e212652db5470a4c338c31e8456881
[15:32:21] mustmodify: https://gist.github.com/mustmodify/05e212652db5470a4c338c31e8456881#file-gistfile1-txt-L11
[15:35:38] mustmodify: I tried to recompile (which I did earlier successfully) and it failed this time.
[15:47:59] roelof: mustmodify: Can you paste the controller and the view to be sure that there is no problem
[16:04:43] Hates_: roelof: the path of the fonts needs to match the path in the CSS file. Generally you would use the asset helper to generate the paths for you
[16:06:04] Hates_: roelof: yes. so if your fonts are in app/assets/fonts/ then you would need url("fonts/aileron-regular.woff2") etc
[16:06:53] Hates_: roelof: if you are using sass or .css.erb files then you can use the asset helpers to make the path
[16:07:20] Hates_: roelof: http://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-font_path
[16:08:06] Hates_: roelof: the fonts can live where ever you want. you just need to make the CSS match
[16:09:28] Hates_: roelof: you can have them in there if you like, but then you have to change the url in your CSS to match.
[16:14:34] Hates_: roelof: your best bet is to use the font helpers like font_path("css/fonts/fontname") that will take care of the assets path and digests when you deploy to production
[17:14:13] roeloif: Hates_: thanks, I change the css line to this : src: font_path('fonts/aileron-regular.woff2') format('woff2'), font_path('fonts/aileron-regular.woff') format('woff'),
[17:47:56] roeloif: Hates_: thanks a lot, I have now the layout I wanted. See : https://ticketee-wissel.c9users.io/
[18:01:16] roeloif: last question: how can I make this work in rails : <svg> <use xlink:href="assets/img/symbols.svg#bar"></use> </svg>
[19:09:48] mustmodify: I'm sure this is super obvious. But I guess I just need to talk it through. Feel free to jump in if you already know how to do it.
[19:10:40] mustmodify: As someone maintaining a very complicated CMS for medical data, I need to provide justification of why I made an addition, change, or removed something so that we can go back and see what was going on.
[19:11:51] mustmodify: So for instance... say there's a "field" model. And someone adds a field. As part of that addition, or if they make a change, there should be a record created indicating who did it, their reason aka "commit message", and ... basically I guess that's it.
[19:12:39] mustmodify: and I'd really like to be able to make several changes and then commit, but that doesn't seem realistic.
[19:14:12] mustmodify: So I could either transition to using git as the backend storage for my app... which would be AWESOME if really weird...
[19:14:40] mustmodify: or I could add a Change model to my app and accepts_nested_attributes_for :change
[19:15:27] mustmodify: and I'd have to do something, presumably in the controller, to get the fields changed and dump them in some readable way, like field.changes.to_json or something
[19:18:43] mustmodify: Hates_: Doesn't ask for commit messages. The paper trail is cool, but doesn't meet the primary requirement.
[19:22:37] Hates_: mustmodify: you can use metadata or a custom class to store your commit messages I suppose
[19:23:34] mustmodify: smathy: I was looking for the "he does exist" clip from Harry Potter but couldn't find it.
[19:27:40] mustmodify: smathy: Although I still like the idea of using git as a back end and being able to branch and merge data.
[20:45:03] Limix: Hi all, is there a way to use an erb view as the html body of an email using mailgun?
[20:45:50] Limix: I guess the real question is, how can I manually render and erb file to a variable so I can then pass that to the correct mailgun method?
[20:49:31] Radar: Alternatively: https://github.com/HashNuke/mailgun#sending-mail-using-actionmailer
[20:50:04] Limix: any thoughts on mailgun? So far I’m loving it, but I haven’t looked at anything else
[21:10:04] hnanon: I have this in my view: https://gist.github.com/anonymous/9ae533d3c1cf1bad33c93ba129334022
[21:13:13] weaksauce: hnanon where is the controller code that's calling this method that has a rescue clause
[21:13:47] weaksauce: typically you'd do a render edit_path and iterate through the errors in the model that you've added
[21:15:06] hnanon: weaksauce: I have this in my controller create action: https://gist.github.com/anonymous/d9b7819a560ca418e03badfd8a3b009b
[21:18:47] hnanon: weaksauce: And in my view I have: https://gist.github.com/anonymous/302618684e68d85ffde39b55b02e9601
[21:24:39] weaksauce: have you read this hnanon http://guides.rubyonrails.org/action_controller_overview.html#the-flash
[21:30:27] hnanon: weaksauce: Looks like flash.now might work since I want to show the error without redirecting?