#RubyOnRails - 17 April 2016
« Back 1 day Forward 1 day »
[00:37:02] michael_mbp: https://github.com/plataformatec/devise/blob/master/lib/devise/token_generator.rb#L20
[02:23:12] siaW: cause i have some images in my public folder and trying to access them from heroku i get an error that there’s no route matching the url
[04:50:34] helpa: Guest92645: Show rather than tell. Explaining your problem with code, stacktraces or errors is always preferred to explaining it with just text. Show us what's happening, rather than telling us. Put the code on https://gist.github.com and then give us the HTTP link to the Gist.
[10:05:18] Andr3as: i have no code yet, lets say i have a user and there is two bolean fields - admin and author - and i want to built the menu according to those fields. i have a user menu, an admin menu and a n author menu.. when someone is an admin, i want to show all menus, when someone is an author i want to exclude the admin menu, but i do not want to show the author menu twice.. any hint on how to handle that (very beginner question maybe,
[10:15:58] Hates_: Andr3as: the basic way would be to use an if/else check. first see if the user is an admin then show the admin section, then for the author menu if the user is an admin or an author then display that section too
[10:16:48] Andr3as: Hates_: yeah, thats what i thought too, but the caveat is, an admin should see the author section too
[10:20:42] Andr3as: or, maybe a helper method and do the author check in that, instead of a normal boolean comparison
[10:20:55] Hates_: Andr3as: you have to sections, admin and author. If you're an admin show the admin section, if you're an admin or an author show the author section. So then it's not repeated
[11:31:36] pcpanic: Sup peoples, stupid question here, how do I know if I am using rbenv or rvm? `which rvm` and `which rbenv` both have outputs
[11:33:46] siaW: my app on heroku stores images in the public folder. yesterday i could view the images, this morning i get “
[11:46:27] sevenseacat: siaw: you know how I told you a few days ago you needed to store your external images and assets somewhere like s3? yeah.
[11:47:42] siaW: yes i know. that’s what i wanted to do. and that’s what i’d do. but there’s this tiny app i’m working on and the senior there is insisting i find a way to store images in the db or the app itself
[11:48:44] siaW: i told him about s3 advantages and why it’s a bad idea what he’s asking me to do and he told me to “cut the crap and get the job done”
[13:05:51] fox_mulder_cp: pwnd_nsfw: by default hosting planned to work based on docker image with apache+php - container per site
[13:09:55] fox_mulder_cp: oh, email, domain registration and all other images for docker planned too
[13:11:58] fox_mulder_cp: now point of failure only storage - i can't select from ceph, gluster ort some other fs for cluster tolerance ^(
[13:13:49] michael_mbp: hmm, RSpec feature specs seem like they are lacking something in their 'scenario' syntax.
[13:14:45] michael_mbp: i.e. scenario 'visit sign-in' // it says what we are doing, but doesn't convey what the outcome should be.
[13:16:30] fox_mulder_cp: michael_mbp: when make a alpha of my panel, me be push it to gh and somebody try to help me with tests
[13:17:15] michael_mbp: fox_mulder_cp: hard to comprehend you mate. Use English as it was intended to and better yet share a gist of your issue.
[13:23:49] michael_mbp: resorting to the likes of scenario "On completing 'Forgot your password?', receive password reset email instructions"
[14:43:43] fox_mulder_cp: hm. can some help me with devise user and its polymorphic relations to client and reseller classes>
[15:25:56] mice: i'm trying to write a little app to manage my own media files that i have all in the same directory, jpg, mp3, mp4, 3gp, wav ... so i list the directory with Dir.glob and then trying to view or listen to the files through the app, so far it looks something like this https://gist.github.com/mices/bc681e47ec753a8be35d5d8fb8cbab90 but i'm not sure if this approach is worth debugging, before i go any further with this app i wanna ask am i taking the righ
[15:26:44] apeiros: adaedra: I guess they figured they've been wrong when they thought hash was a hash? :D
[15:28:18] fox_mulder_cp: mice: hm, i think that u can create class media which has_many media (polymorphic) and foreground job to perioric rescan directories with media
[15:31:03] mice: fox_mulder_cp: a model? should be a subclass of ActiveRecord::Base ? i dunno what you mean by create class media
[16:19:44] roelof: I have done the Micheal Hartl's tutorial but still a little bit confused about something
[16:21:10] roelof: Suppoise I have a Profit model which has many Category . Category belongs to Profit. Suppose I have a category named "post". Is there a way I can find out to which part the profit model is ?
[16:27:02] bookies: Good day. Can anyone take a look here? http://stackoverflow.com/questions/36677284 . Thanks
[16:33:20] rails918: Hi guys, I have a form.submit in a view I would like to change from a HTML input to a <button> http://pastebin.com/raw/GnTbAzJS
[18:00:17] bauerbob: hi. some of my models don’t trigger the callbacks. i tried after_commit, after_save. how do i find out why?
[18:05:21] ponzii: How do I express this Pg sql in Active Record: to_char(eventdate,'DD Mon YYYY') as eventdate
[18:09:45] bauerbob: tildes: they trigger a worker, which will do another update in the database, an update to a counter. but the counter remains the same
[18:10:48] tildes: bauerbob: it could be they are called, but something within the method is not working as expected
[18:11:48] tildes: bauerbob: it is possible to do unexpected things, or not do them, without exceptions, depending entirely on the methods you are using
[18:11:51] bauerbob: okay… so if i only do a “puts ‘you triggered me’” i should see that in the logfile, right?
[18:14:57] bauerbob: lol, you’re right, that’s it. the trigger works, so my worker seems to run into an error. unfortunately the error doesn’t appear in the logs. but at least i know where to search for the error now
[18:19:03] tildes: it allows you to set a breakpoint in your code, check what are the current variables, if I remember correctly even change variables on the go, and continue execution step by step
[18:20:44] tildes: bauerbob: is there ruby code you are able to edit somewhere in there? if yes, you can introduce byebug
[18:21:35] tildes: bauerbob: I hope I'm not promising too much here, but again, that's something I might try also
[18:21:57] tildes: bauerbob: you can also set up your own logger in your worker, and just write stuff in a file from the worker
[18:26:03] bauerbob_: re. what i wanted to say is: looks like i have to change the way i set my custom exception handler
[18:43:01] fox_mulder_cp: i need help with relations - in guides we have polymorhic relations, when one class(image) can be attached to user and product
[18:44:48] fox_mulder_cp: but i need attach to one class (customer) two different profiles - for personal user (one set of options) and for enterprise user (second set of options - financial data for invoices)
[18:46:58] someish: I’m using devise’s confirmable module, and I’ve set it up so that when a user is created, they receive the confirmation email and are asked to enter a password after clicking the confirmation link. The weird thing is that the devise confirmable mailer is sending the raw token instead of the digested token. Also, I’m definitely using the @token variable in the mailer view as everything I’ve read on google suggests.
[18:55:29] pipework: meatchicken: Generally I just send down JSON where the key is the CSS selector and the value is that HTML that you've ran through ERB.
[18:56:33] pipework: Why might you need dynamic JS? I generally suggest to avoid dynamic JS. What are you doing exactly? I don't have all the history if you already described what you're doing.
[19:06:52] enkristoffer: Is it possible to use HTML tags in Rails' form labels? Something like this, except working :P <%= f.label :cover, '<strong>test</strong>' %>
[19:18:38] smathy: fox_mulder_cp, why not just a polymorphic association for customer -> two different profiles too?
[19:20:12] smathy: fox_mulder_cp, exactly the same as you'd have in your image -> user/product situation. Something like: belongs_to :profile, polymorphic: true
[19:22:15] fox_mulder_cp: smathy: oh, it's hardly for me ( as i see, that is a reverse situation for one image for user and product
[19:24:53] smathy: fox_mulder_cp, well, assuming that the example from the guides you're talking about is actually this one: http://guides.rubyonrails.org/association_basics.html#polymorphic-associations So not (as you said) from image to user/product but from picture to employee/product, then this is exactly the same as you'd have with your customer -> personal_profile/enterprise_profile.
[19:27:52] fox_mulder_cp: smathy: hm. in my app client is primary class, and how to map two different classes into one virtual class, as 'imageable' from guides?
[19:29:17] smathy: fox_mulder_cp, seriously if `belongs_to :profile, polymorphic: true` didn't immediately set you on the right course then yes, I think this ideology is beyond you.
[19:31:50] fox_mulder_cp: smathy: hm. now i try to use jsonb for store this data. now it's easyable for me
[21:28:55] SteenJobs: hey guys - what’s the best way to solve the issue of strong params returning nil when update is called but no value has been submitted?
[21:30:01] smathy: Strong params returning nil when no values are submitted doesn't sound like an issue to me, sounds like expected operation.
[21:31:00] SteenJobs: smathy: generally yea - thing is, we have an avatar for the profile model, but the upload is its own form. and its optional to upload during onboarding, so if the user continues without uploading an image, there are no params[:profile]
[21:34:15] SteenJobs: smathy: so i can make it hacky by adding conditionals when updating the avatar on the profile model, but using strong params keeps things nice and neat
[21:42:03] smathy: SteenJobs, if you have two separate forms then there are two separate submissions to your controller, and so I'm not sure how you think them uploading their profile in one form is going to impact the params sent in the other form.
[21:42:59] SteenJobs: smathy: it’s a multi-step form, so each step corresponds to different params - the avatar view is the only view that allows no params to be passed. all steps post to the same controller action.
[21:43:40] SteenJobs: smathy: although there is a placeholder image, so the solution may be to just add the placeholder image in params and udate the profile pic that way, should they not provide an image, rather than hardcoding the placeholder image in the frontend when a user is lacking a profile pic
[21:44:32] SteenJobs: fox_muld1r_cp: nope. and the whole multi step process is built and solid. and each step has its own validations. my only issue is the avatar view because it’s possible to submit the POST req with no params
[21:45:19] fox_muld1r_cp: SteenJobs: def create .. define profile.image = '/path/to/placeholder' if profile.image.nil? ??
[21:46:15] SteenJobs: but i needed a bit more flexibility, and i found some dude who wrote an excellent service for handling multi step forms
[21:47:35] smathy: SteenJobs, strong params wasn't designed to work with these sorts of workflows, so when you use them you should expect them to provide solutions for strong_params.
[21:48:43] SteenJobs: smathy: well the secret is, the profile pic upload is kind’ve its own thing, its not really part of the multi step form technically, since i route to that view from other areas of the app - but yea, i’ll come up with a solution
[21:49:02] SteenJobs: alhtough i really like that dude’s implementation - does he/she hang out here ever?
[22:04:11] cmhobbs: hi! i'm upgrading from rails 3.2 to 4.0 and i've put activerecord-session_store and protected_attributes into my Gemfile, however my tests are breaking because it says i need to include those in my Gemfile
[22:04:20] cmhobbs: i've already bundled and i see them in my Gemfile.lock. what could i be missing?
[22:14:36] cmhobbs: i've had a half dozen gems i've required manually at the top of config/environments/test.rb just to see how far it's affected
[22:17:17] cmhobbs: it'll complain about some uninitialized constant, i'll add a require line for the gem that provides that constant to the test environment, and it'll complain about a new uninitialized constant
[22:41:28] Radar: ACTION is going to need to buy another walk if he wants to continue to chalk things up
[22:45:13] SteenJobs: smathy: ended up creating a separate update_avatar action, and using strong params with only permit and no require, so no nil if left blank