#RubyOnRails - 12 June 2018
« Back 1 day Forward 1 day »
[03:07:16] CuriousMind: Hi, I deployed my app to heroku, but it won't work. Can someone help me solve this problem?
[03:08:09] helpa: What "didn't work"? Did your server not start? Did your computer explode? Did your webpage turn bright pink? Did your client not pay your bill on time? You may have to be more specific. A Gist (http://gist.github.com) of the code that doesn't work (and the error you are getting) will be helpful.
[03:12:08] CuriousMind: sevenseacat: Here is my heroku logs output - https://gist.github.com/Osagiede/0a6f52ad875108ce33025725cb4c3543. The error says Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? sqlite3 is not part of the bundle. Add it to your Gemfile. (Gem::LoadError) but it is in my Gemfile.
[03:13:13] sevenseacat: you'll need to swap to using postgres for production, or better yet, postgres for all environments.
[03:14:20] CuriousMind: sevenseacat: I do have postgres for production. Here is my Gemfile. https://github.com/Osagiede/sample_app/blob/master/Gemfile
[03:14:53] CuriousMind: Why am I doing this? I am following an online guide. https://www.railstutorial.org/book/static_pages
[03:15:43] sevenseacat: https://github.com/Osagiede/sample_app/blob/master/config/database.yml your database.yml isnt configured to use postgres in production
[03:18:10] CuriousMind: sevenseacat: That makes sense. I don't know how to do this though. I guess refer to the ruby guides online
[03:19:04] CuriousMind: sevenseacat: I'm just trying to learn rails and I couldn't continue this chapter for two weeks cause of this problem
[03:19:35] CuriousMind: sevenseacat: Ok thanks. In the meanwhile, I'll search for how to configure my database.yml file
[03:21:14] sevenseacat: shouldnt need to configure it for heroku - checked it against a sample app I have that deploys to heroku
[03:34:52] sevenseacat: trying to get the new heroku client set up here so I can try deploying your sample app
[03:49:31] CuriousMind: The third line of heroku logs says "Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? sqlite3 is not part of the bundle. Add it to your Gemfile. (Gem::LoadError)"
[03:50:13] CuriousMind: Not third, second line sorry. Here is the full line - "/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/rubygems_integration.rb:377:in `block (2 levels) in replace_gem': Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? sqlite3 is not part of the bundle. Add it to your Gemfile. (Gem::LoadError)"
[03:51:06] CuriousMind: sevenseacat: remote: Verifying deploy... done. To https://git.heroku.com/rocky-ravine-35505.git c0b5aea..6bc3713 master -> master
[03:58:14] CuriousMind: As you can see, I am trying to learn rails. Besides from guides.rubyonrails.org. What else is a good resource that I could start learning and practicing from?
[03:58:42] CuriousMind: Rails is complicated to me and I am trying to learn all the different options and purposes of the different files and how to configure this and that etc
[03:59:02] sevenseacat: I co-wrote what I think is a good resource, but it never got updated for Rails 5 :/
[03:59:04] CuriousMind: I just finished an SQL tutorial today. I did http://www.sqlcourse2.com/other_links.html. I'm trying to get it together
[04:00:04] sevenseacat: I don't know what other resources out there - I think railstutorial got a bit whacky
[04:00:09] helpa: Rails 4 in Action - http://manning.com/bigg2 - An excellent book combining Rails and TDD/BDD development. Written by Rebecca Skinner, Steve Klabnik, Ryan Bigg, Yehuda Katz
[10:46:47] drale2k_: Is it save to pass a param directly to AR .where? Like Computer.where(id: params[:computer_id])
[10:47:05] Radar: drale2k_: yes in that case it is fine. Interpolation is usually where it goes wrong.
[11:08:20] tbuehlmann: drale2k_, just so you know: when passing an ActionController::Parameters object into .where directly and a key is not permitted, rails will raise an ActiveModel::ForbiddenAttributesError
[11:15:28] drale2k_: tbuehlmann: thanks know that, but ID and any foreign keys should be allowed by default right ?
[11:16:57] tbuehlmann: key-value pairs in AC::Parameters are not permitted until you manually permit it
[11:46:17] mguex: o/ I use ror5 with active storage and have several pages that have their routes configured in the db. The controller finds the page by the route. Slashes are a requirement (e.g. "/foo/bar"). So in routes.rb I got "get '/*route', :to => "page#show", :as => :show_page". This works as expected, however the activestorage routes under /rails are also caught by it. Any idea how to fix this?
[11:47:09] mguex: I already tried copy pasting the routes of active storage above the catch all which gives me errors that the routes are already defined
[11:48:23] mguex: One idea I had was to move the activestorage route initializer in front of the one of my app (I assume it is currently executed after routes.rb of my application), however I don't know how to change that
[11:50:47] tbuehlmann: mguex: not sure the latter is possible with a string pattern, but it's easily possible with a custom constraint
[11:52:26] tbuehlmann: a constraint could look like this: https://gist.github.com/tbuehlmann/b8d28c3ca46c33fb96aeb6922572ce6e
[11:52:30] mguex: for reference: get '/*route', :to => "page#show", :as => :show_page, :route => /(?!.*rails).*/
[11:58:58] mguex: tbuehlmann: curl https://gist.githubusercontent.com/tbuehlmann/b8d28c3ca46c33fb96aeb6922572ce6e/raw/c2661d09b0d0056f4e4085fd15572b3e992e4a7b/not_starting_with_rails_constraint.rb | sed -e 's/\/rails/\/rails\//g'
[12:03:57] za1b1tsu: Hello if anyone is using RubyMine, is there a built-in way to open a gem as a project?
[12:15:57] mauro1254: Hi folks, is there a gem that et you consume json web services and create associations with ActiveRecord models? Looked at ActiveResource and Her, but unfortunately association to AR models is not supported.
[12:28:34] syndikate: Is there a way to put a unique constraint/index on a specific value? As in I need the unique index on two fields when one of the field has a specific value
[15:10:58] cjohnson: syndikate: Well presumably you would need to join the database channel for the relevant DBMS you're using and ask there
[15:22:57] mguex: syndikate: http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validates
[15:26:45] Travis-42: I'm trying to use the rails cache helper when building a large xml response for a feed, but if I use caching, memory usage quickly grows out of bounds by hundreds of megabytes per request -- almost all on this line of the rails cache helper when writing an uncached fragment "fragment = output_buffer.slice!(pos..-1)" -- is there a more efficient way of caching fragments of xml responses?
[15:29:05] mguex: syndikate: https://0bin.net/paste/+Rro9EorzIu23qKI#avj4mT5xmYzh1TMaT77e3x6G029euV3DnhuAyrLouZ6
[19:53:44] mauro1254: Hi folks, is there a gem that et you consume json web services and create associations with ActiveRecord models? Looked at ActiveResource and Her, but unfortunately association to AR models is not supported.