#RubyOnRails - 15 November 2017
« Back 1 day Forward 1 day »
[02:24:20] nachoman: (Devise) is it ok if I use devise_for :admin, class_name: 'User' to avoid writing all routes for admin/...<paths> again?
[02:48:32] nachoman: Thanks. I'm using polymorphic associations between User and Admin, Customers, ... should I use STI? is it simpler?
[05:59:44] thither: Okay this is trippy. I've monkey-patched a method into ActionDispatch::IntegrationTest (one that authenticates me with my API). When I try to call the function I'm told that there are the wrong number of arguments (given 1, expected 0), even though I am not calling it with any arguments.
[06:00:05] helpa: You have not provided enough information to debug your problem. Please provide this information: https://gist.github.com/radar/5384431
[06:00:17] thither: However, if I update the function to take an argument the tests all fail with (given 0, expected 1)!!
[06:04:33] thither: sevenseacat, https://gist.github.com/teaearlgraycold/0bd321075e534d40cdfd52542d45b6e6
[06:32:44] Technodrome: say you have a checkbox for a descripton, and you got some search results, the checkbox will toggle the description , what is the best way to implement this?
[06:33:47] sevenseacat: you might have to clarify what you mean by 'a checkbox toggling a description'
[06:54:37] Technodrome: i just woke back up after a good nap, i haven't tried a solution yet, i'm about too
[07:16:14] alexday: https://gist.github.com/argentum47/f03fae9655d1f001af73e4b21eef40e6 so I have a file <env>.rb which looks like default.rb and then in the file1.rb file I have to actually render an erb template. So in there erb template there will be something like <%= for @default['..']['..'] .... %> . Once I am able to put the default hash from default.rb into file1.rb's Abc object. I can do the rest. I am stuck here
[07:25:24] Technodrome: sevenseacat i'm still not completely sure on the best way to implement it, and this is one thing that you could sink 8 hours into
[07:41:44] alexday: dminuoso: ok, I will try once more. I have a file called production.rb which looks like default.rb. I have to use this hash in default.rb to render an erb template. The code to render that will go inside file.rb. But the problem is since in default.rb there is no intialization being done, when I try to require_relative default.rb or self.instance_eval(IO.read "default.rb") it doesn't work because of
[07:43:50] dionysus69: how do I extract country codes -> country name hash out of country_select gem tag?
[07:44:54] dminuoso: alexday: Not making sense still. Too many things you assume I know about your use case.
[07:49:03] alexday: If it is, I can't do that, because its a constraint. If i change that it will break all other things. but can I use metaprogramming to do that in file.rb
[10:43:20] dionysus69: I refreshed form page, got CSFR token, then included into a request made by postman, it complains about invalid authenticity token. what did I do wrong
[11:38:22] dionysus69: what's the right way to submit params from a post request from an API to devise? form-data?
[12:28:54] marahin: Hello! I can't seem to find any documentation regarding this, but: https://github.com/rails-api/active_model_serializers/issues/671 - is there a way to version serializers just like versioning the API?
[12:29:17] marahin: So /v1/blah would access serializers/v1/BlahSerializer, and /v2/blah would access serializers/v2/BlahSerializer?
[14:16:40] dminuoso: marahin: You can pick an explicit serializer by passing a key serializer/each_serializer with the serializer as a value
[14:17:17] marahin: dminuoso yes, but that's not nice :(. I actually managed to get around that - I've been using AMS 0.10.0, I bumped version to 0.10.7 and now it properly discovers the namespace (and finds proper, versioned, Serializer :))
[14:17:41] marahin: So it seems that between 0.10.0 and 0.10.7 there's been either code fix or update that got it working :)
[14:17:57] dminuoso: marahin: *shrugs* - I just explicitly name serializers (I use jsonapi-rb though)
[14:18:45] marahin: dminuoso I guess whatever you're aiming for, I'm currently on my first assignment in a new workplace, so I'd like to get it as shiny as I can. :-)
[14:18:56] dminuoso: marahin: The thing is I found that I wasted *so* much time learning how all these magical components need to be treated to "save time"
[14:19:10] dminuoso: that all the "time saved" I ended up spending fighting/debugging/reading docs about that magic.
[14:19:32] marahin: haha, yeah, that's true. I could've just declared that I want this given serializer to be used, and it would work - and instead I browsed through dozen of issues at /active_model_serializers looking for a soulmate that has the same issue as I :P
[14:21:05] dminuoso: marahin: I mean I do understand the quest for writing elegant code. But silent code is not elegant.
[14:22:09] marahin: dminuoso: that's all true. But OTOH I find having to type ", serializer: PersonSerializer" three times in the same file, then ", each_serializer: PersonSerializer" once kinda repetitive.
[14:25:07] dminuoso: marahin: You can set up a single method whose responsibility is just invoking render
[14:25:54] marahin: dminuoso I've thought of that too. But if I am to read and get to know how to do it nicely, why not fix the thing that caused me to think about this? :P
[14:26:00] dminuoso: marahin: After years of rails development I found that I became a slave to adhering to rails principles.
[14:26:11] dminuoso: Functionality and design were designed around autoloading and implicit naming of things.
[14:26:36] dminuoso: Which after a while lead to weird code. I noticed this whenever I would open up some file and kept wondering "where does this come from?", "what magical assumption is being made here?"
[14:28:13] marahin: I tend to think that the person who pays me excepts me to do this as close to the Rails standard as possible (I'm not a senior developer nor any close to it yet), so I try to do my best to get stuff working, to actually perform good, and to look good for any random Rails developer that comes through.
[14:29:18] marahin: and also I have a weird sense of faith for libraries that I use - "oh, so it's supposed to work magically? I'm sure it will!"
[14:59:00] noob_on_rails: hey all , i'd like to ask , is fork used in ror apps to give some good solutions?
[15:31:09] airdisa: Heroku is free, but it's also a tangle of agreements, and customizations that could confuse you later
[15:31:52] airdisa: I would recommend that you know some cmd line work to get it working on your computer first, or go straight to renting a cloud machine
[15:33:33] airdisa: so, first step, understand that your computer is capable of being its own server
[15:34:56] airdisa: you'll need to follow instructions for installing Ruby on Linux first, then add the Rails Gem
[15:36:42] airdisa: so, log in using SSH to your Digital Ocean Linux computer, and follow instruactions for installing Ruby on Linux first
[15:37:37] airdisa: I bet there is a Digital Ocean instruction page for doing this, since it's pretty commonplace
[15:40:32] airdisa: the ones I looked at just now, seem zany to me, I would start with plain Ruby, then add the Rails Gem and go through a tutorial on Rails to get a website up and running
[15:42:38] airdisa: once you're running, I wouldn't run `rails rack -s` but use `rails -help` and just `rails server`
[15:44:22] airdisa: the -p option lets you choose to bind the service with any open port number you like
[15:45:19] iamarun: and what is this https://github.com/mperham/sidekiq i was told this was to be used to set up rails server
[15:46:23] airdisa: I don't use sidekiq (at this time) although I think it's a background process runner like cron job (I think), and rails has that built-in now
[15:46:53] airdisa: I would get familiar with how much stuff Rails 5 has that old posts will recommend some gem for when now it's unnecceary
[15:47:54] airdisa: the basic Rails framework is pretty mature now, and much of what used to require gems, no longer does
[15:49:29] airdisa: to add something like Siedkiq, you would install the Gem (following instructions), and then you would add reference to it in the Gemfile (root directory of the app)
[15:50:46] airdisa: installing Ruby can take a long time, by the way, as long as you think it;'s working, I wouldn't Ctrl-C out
[19:28:03] baweaver: https://stackoverflow.com/questions/1129781/has-and-belongs-to-many-avoiding-dupes-in-the-join-table
[19:30:42] FrostCandy: Hi guys before i blow up my test database, is there any differnece between rake db:migrate and rails db:migrate? We use active record if that makes a differnce.
[19:55:33] FrostCandy: apparently there is a difference based on rails version. early versions need rake
[20:16:24] megan1993: Hello! I'm wondering if I could write this more elegant, something in a one-liner: expect(person.dosomething(@x)).to include(a_kind_of(X)) expect(person.dosomething(@x)).to include(a_kind_of(X::Y))
[20:17:12] megan1993: Couldn't find any possible way to put to classes in the include(a_kind_of) function (https://relishapp.com/rspec/rspec-expectations/docs/built-in-matchers/include-matcher)
[20:31:25] tcopeland: FrostCandy: FWIW some more details on that rails/rake thing here http://guides.rubyonrails.org/initialization.html#rails-command-rb
[21:07:14] mcr: I'm working on David (CoAP server), trying to improve the ResourceDiscovery mechanism. I would like to annotate which routes should be discoverable. I'm looking for a gem (or FAQ) that extends ActionDispatch::Journey::Route (and/or Path?)