#RubyOnRails - 18 May 2019
« Back 1 day Forward 1 day »
[01:51:36] randomuser1012: I'm having trouble starting up a postgresql database. The problem is that in order to run it, I need to make sure I run migrations first. In order to run the migrations I need to swap over to my postgres account, however, I get some errors when I try and do that.
[01:53:27] randomuser1012: I try and run `rake db:migrate` and I get a few `Ignoring GEM because its extensions are not built. Try: gem pristine GEM`
[02:14:52] weaksauce: i imagine there is a way to change the path using a bundler setting to make it accessible to both users
[10:11:15] IGnorAND: @weaksauce I want an API app. However not all my data comes from a database. I have an external app with clients. I want to use this list of clients in my app. So when I do a GET /clients I want to call the index method in the controller which should perform an request on the other app instead of on the db.
[10:38:03] IGnorAND: My api however currently gives me a response with a data and meta hash. In the data I have an array of clients. I have been able to do the api request, however I want to output my code as JSON too, so I was thinking of using something like jsonapi. And I am somewhat succesful, but I feel I am doing something wrong
[10:38:05] IGnorAND: https://gist.github.com/nuheluxulu/7de68bd8968b96d970b5cc83c7edac48#file-clients_controller-rb-L9
[12:24:57] randomuseragain: I'm having a problem trying to run migrations from my postgres account. I'm using my postgres account to communicate with the postgres db, however, when I try to run migrations I get this error: https://dpaste.de/71HT
[13:11:22] haxx0r: i want to make ActiveAdmin accessible only if you have a certain cookie, otherwise 404 is thrown. i have issues to hijack active_admin to inject that. so i wonder if i can inject that on routes level. maybe a constraint?
[14:56:53] randomuseragain: I'm having some issues with running migrations from my postgres account. When I try and run `rake db:migrate` I get the following errors: https://dpaste.de/71HT
[14:58:02] randomuseragain: It may be an issue with bundler's path but I'm not too sure how to go about fixing it
[14:58:50] havenwood: randomuseragain: Usually it's due to multiple Rubies installed. Does it work with `bundle exec rake db:migrate`?
[14:59:18] havenwood: randomuseragain: Sanity check `which bundle` and `gem which bundler`? It's the right Ruby?
[15:00:41] havenwood: randomuseragain: From those warnings, look like you might need a: gem pristine --all
[15:01:33] havenwood: randomuseragain: In modern Rails, the `rake` commands are aliased to `rails`, so you can: bin/rails db:migrate
[15:04:28] randomuseragain: My postgres account doesn't have the rights to install system ruby gems - https://dpaste.de/kmv8
[15:06:11] havenwood: randomuseragain: It seems there are two Rubies involved here, a system one and an RVM one.
[15:06:55] havenwood: randomuseragain: You need to be able to install the gems from the Gemfile.lock to run the app.
[15:07:12] havenwood: randomuseragain: As the error suggests, you can vendor them if you want to install locally in the app directory.
[15:07:27] randomuseragain: when I ran `gem pristine --all` I got the following https://dpaste.de/xrKW
[15:08:58] havenwood: randomuseragain: Install gems somewhere you have permission to install gems. Run `bundle` from the account that can install gems.
[15:10:31] randomuseragain: havenwood: I just tried checking if I could use bundle from my primary account and it looks like that isn't right either
[15:11:00] randomuseragain: gem which bundle ---> ERROR: Can't find Ruby library file or shared library bundle
[15:12:05] randomuseragain: ERROR: While executing gem ... (Errno::EACCES) Permission denied @ rb_sysopen - /home/jrodr4544/.rvm/gems/ruby-2.6.0/gems/bundler-2.0.1/exe/bundle
[15:13:22] havenwood: randomuseragain: Is that your own home dir? Seems there are a lot of permissions issues going on.
[15:18:59] randomuseragain: havenwood: Well, I'm running bash in windows. Not sure if that might be part of the problem
[15:20:54] randomuseragain: gem which bundler /home/jrodr4544/.rvm/rubies/ruby-2.6.0/lib/ruby/site_ruby/2.6.0/bundler.rb
[15:25:17] randomuseragain: havenwood: I use my postgres account to run migrations. I can't do it from my primary account because `PG::ConnectionBad: FATAL: Peer authentication failed for user "postgres"`
[15:26:55] randomuseragain: havenwood: Also, thanks for helping get the permissions fixed on my primary account
[15:27:23] havenwood: randomuseragain: Now that Bundler's working on your primary account, from there run: bundle
[15:31:08] havenwood: randomuseragain: Usually to share gems between accounts, you'd either use vendor gems locally into the app directory or use a system gem installation both can share. Alternatively, you could install gems separately for both accounts.
[15:34:41] Exuma: Hey, how do I get the URL to a CSS file instead of just the path? Similar to how the root_path vs root_url will take the path and the later will take the full current URL
[15:35:00] Exuma: I have ot interact with an API that requires me to pass a CSS file and i want to pass one of the compiled sass files in my app
[15:36:06] Exuma: css absolute url* - its a payment iframe so its going to be loading the file immediately in the iframe, which is why I need to do this quirky thing
[15:59:53] randomuseragain: havenwood: If i'm not mistaken, rake isn't a gem therefore, I should be able to use it from another account. In this case, my postgres
[16:03:18] randomuseragain: havenwood: the only reason I have the postgres account is to be able to run migrations
[16:03:31] havenwood: randomuseragain: Along with did_you_mean, minitest, net-telnet, power_assert, test-unit and xml-rpc - rake is a "bundled" gem that ships along with Ruby.
[16:03:47] havenwood: Unlike default gems, which also ship with Ruby, bundled gems can be uninstalled.
[16:06:17] randomuseragain: I just realized I've got two different ruby versions running. In my postgres account - ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
[16:06:32] havenwood: Default gems are bigdecimal, io-console, json, openssl, psych, rdoc, rubygems, webrick, cmath, csv, date, dbm, gdbm, sdbm, etc, fcntl, zlib, strscan, stringio, scanf, ipaddr, fileutils and fiddle. A bunch were gemified from the stdlib in 2.5.
[16:06:40] randomuseragain: In my primary account - ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
[19:18:44] weaksauce: perhaps changing bundle config path /some/shared/path would help randomuseragain
[19:21:26] weaksauce: IGnorAND not sure what your question is actually. can you be a bit more specific than "And I am somewhat succesful, but I feel I am doing something wrong"
[19:29:06] weaksauce: i'm not sure but something accessible by both accounts and not likely to be overwritten by a cache purge.
[19:29:55] weaksauce: you can do it under ./vendor/bundler if you want. just .gitignore that directory
[19:30:16] randomuseragain: At the moment, I have bundler working on my primary account and when I run `rails db:migrate` I'm no longer getting the same errors as before
[19:31:42] randomuseragain: weaksauce: I'm getting this instead from my postgres account: https://dpaste.de/iqpE
[19:34:40] randomuseragain: weaksauce: `gem install bundler` gives me permission error ; gem install bundler Fetching: bundler-2.0.1.gem (100%) ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /var/lib/gems/2.5.0 directory.
[19:37:55] randomuseragain: I tried doing that but im not able to use a version manager at the moment
[19:39:46] randomuseragain: Well, I'm trying to swap the version from my postgres account and i get: Command 'rvm' not found, but there are 21 similar ones.
[19:43:22] weaksauce: either install a system ruby and keep that up to date (not always the best move) or install rvm on the postgres account or set postgress permissions temporarily to install bundler or give your app account permissions to run db migrations
[20:30:36] randomuseragain: weaksauce: Thanks! Just got the migrations to work. Although I'm not sure if this was the appropriate way to go about it, I install rvm and bundler on postgres account and that led to successful migrations
[20:37:52] weaksauce: randomuseragain that works. i doubt there is a "best" way on things like that.