Activity Graph

Page 1 of 46 | Next »


[08:52:32] DaniG2k: has joined #ruby
[09:40:52] DaniG2k: has joined #RubyOnRails
[09:47:09] DaniG2k: KiferionSpike: can you make a gist with the code plz?
[10:55:54] DaniG2k: Quit: leaving


[07:12:20] DaniG2k: has joined #ruby
[07:12:39] DaniG2k: hello all, I'm trying to stub a method in Minitest (from ActionDispatch::IntegrationTest) but having some trouble
[07:13:01] DaniG2k: I basically want to just return an OpenStruct when a controller method is called
[07:13:23] DaniG2k: the OpenStruct makes use of a param (i.e. params[:amount])
[07:13:52] DaniG2k: I haven't been able to find a way to stub methods in MiniTest while preserving the params
[07:14:29] DaniG2k: the struct would be something like OpenStruct.new({amount: params[:amount].to_i * 100})
[07:44:19] DaniG2k: Quit: leaving


[14:58:25] DaniG2k: has joined #ruby
[15:13:59] DaniG2k: Quit: leaving


[11:56:46] DaniG2k: has joined #ruby
[11:57:22] DaniG2k: Client Quit


[05:13:46] DaniG2k: has joined #ruby
[06:52:52] DaniG2k: Quit: leaving


[07:22:50] DaniG2k: has joined #ruby
[09:24:17] DaniG2k: Quit: leaving
[09:24:25] DaniG2k: has joined #ruby
[09:24:48] DaniG2k: hello all. I'm trying to set up webpacker in my Rails 4 app. However, I cant seem to get it working with CircleCI
[09:25:06] DaniG2k: I've explained the actual error in this SO thread: https://stackoverflow.com/questions/55570569/rails-4-getting-webpacker-to-work-with-circleci/56521522
[09:26:11] DaniG2k: but basically the error I'm seeing in CircleCI is: ActionView::Template::Error: Webpacker can't find application in /home/circleci/octopi/public/packs-test/manifest.json
[09:39:40] DaniG2k: oops sorry, thought I was in the Rails channel. Will ask there
[10:15:36] DaniG2k: Quit: leaving


[06:45:44] DaniG2k: has joined #ruby
[06:46:26] DaniG2k: has joined #RubyOnRails
[06:48:12] DaniG2k: im trying to get webpacker working in a Rails 4 project I'm working on
[06:48:28] DaniG2k: I added the gem to the Gemfile
[06:48:46] DaniG2k: added the javascript_pack_tag to the application htmlfile
[06:48:57] DaniG2k: I've set it up to work with vuejs
[06:49:00] DaniG2k: I think all is well
[06:49:09] DaniG2k: only thing that isn't working is the CI/CD pipeline
[06:50:27] DaniG2k: I think I somehow need to add the webpacker step to my circleci config file but really not sure how/where
[06:51:01] DaniG2k: the error I'm seeing in CircleCI is: ActionView::Template::Error: Webpacker can't find application in /home/circleci/octopi/public/packs-test/manifest.json. Possible causes:
[06:51:39] DaniG2k: any idea how I can fix this?
[06:57:42] DaniG2k: any idea what the correct way to do that would be
[06:58:38] DaniG2k: thanks, will have a look
[07:02:44] DaniG2k: sevenseacat: my webpacker.yml file already seems tobe configured with a production block
[07:03:10] DaniG2k: i also have a test block though
[07:03:24] DaniG2k: it has compile: true and public_output_path: packs-test
[07:07:43] DaniG2k: maybe I need to create that packs-test directory?
[07:25:03] DaniG2k: Quit: leaving


[04:22:29] DaniG2k: has joined #ruby
[05:35:07] DaniG2k: Quit: leaving


[07:29:36] DaniG2k: has joined #ruby
[07:29:50] DaniG2k: has joined #RubyOnRails
[07:30:18] DaniG2k: I have a model called ContainerTypes that has_many containers, as such:
[07:30:19] DaniG2k: has_many :containers, dependent: :restrict_with_error
[07:30:37] DaniG2k: I'd like to add a migration to ensure the `dependent: :restrict_with_error` gets checked at the database level
[07:30:46] DaniG2k: but I'm not entirely sure how to do so. Any suggestions?
[07:32:30] DaniG2k: so I need to add something like `add_foreign_key :containers, :container_types, on_delete: :restrict` ?
[07:32:49] DaniG2k: the Container is the model that has the container_type_id field on it
[07:34:08] DaniG2k: right ok, I'll give it a shot. THanks
[07:50:29] DaniG2k: Quit: leaving


[21:04:17] DaniG2k: has joined #RubyOnRails
[21:06:32] DaniG2k: I am using the ancestry gem for a project. It creates the following column:
[21:06:38] DaniG2k: add_column :commodity_types, :ancestry, :string
[21:06:42] DaniG2k: add_index :commodity_types, :ancestry, algorithm: :concurrently
[21:07:11] DaniG2k: I'd basically like to add an ON DELETE RESTRICT at the database level as well
[21:07:17] DaniG2k: but can't figureout what the syntax is for that
[21:07:19] DaniG2k: any advice?
[22:01:23] DaniG2k: Quit: leaving


[10:33:35] DaniG2k: has joined #RubyOnRails
[10:33:55] DaniG2k: hello all, I'm trying to get Carrierwave to upload image versions to an AWS S3 bucket but it doesn't seem to work
[10:34:02] DaniG2k: I can get the main image to upload just fine
[10:34:10] DaniG2k: but the thumbnail version does not get uploaded
[10:34:44] DaniG2k: I've Googled it a lot but can't seem to find any info on how to save the different versions
[11:56:25] DaniG2k: sevenseacat: thanks for the response. I've posted the code on SO: https://stackoverflow.com/questions/53823063/rails-4-uploading-carrierwave-generated-image-versions-to-aws-s3?noredirect=1#comment94510702_53823063
[11:56:29] DaniG2k: it's super basic
[11:56:46] DaniG2k: main image is being uploaded, thumb doesn't seem to be uploaded :/
[11:58:45] DaniG2k: sevenseacat: actually I just was testing by setting if Rails.env.production? || Rails.env.development?
[11:58:59] DaniG2k: so that it was using fog in development to see if the images got uploaded to AWS S3
[11:59:04] DaniG2k: the main one does, so that works
[11:59:14] DaniG2k: it's the thumb that doesn't seem to get uploaded
[11:59:40] DaniG2k: thumb is 200 wide
[12:00:05] DaniG2k: hmm good point
[12:01:30] DaniG2k: im using Dropzone on the frontend, so the images get resized on the client side before passing to Rails. I have the resize on Dropzone set to 800px
[12:01:45] DaniG2k: so it arrives already with a width of 800 when it reaches the Rails controller
[12:10:39] DaniG2k: sevenseacat: yep carrierwave is performing the main resize
[12:11:00] DaniG2k: i uploaded an image that was 1600 wide, set Dropzone to resize to 1000, and the uploaded image is 800px
[12:11:07] DaniG2k: so that's working
[12:11:28] DaniG2k: ohhhhh jeez
[12:11:30] DaniG2k: i found the error
[12:11:43] DaniG2k: yep the url I was returning was incorrect
[12:11:52] DaniG2k: thanks for helping me reason through that one >.< I feel dumb now
[12:13:36] DaniG2k: so the issue is actually the following: i am serving the images throgh a controller (in order to control which users have permission to see the images and which don't)
[12:13:57] DaniG2k: the show method returns `send_file my_image.file.path, disposition: :inline`
[12:14:09] DaniG2k: the thumb method returns `send_file my_image.file.thumb.path, disposition: :inline`
[12:14:29] DaniG2k: which works fine when storage is :file
[12:14:50] DaniG2k: for :fog storage I probably need to return the url, not path
[12:14:53] DaniG2k: I think that's it
[12:20:46] DaniG2k: sevenseacat: you've been in this channel for ages. I respect your faithfulness to Rails
[12:21:05] DaniG2k: what do you do? full-time dev?
[12:21:29] DaniG2k: heheh awesome
[13:16:27] DaniG2k: Quit: leaving


[11:57:04] DaniG2k: has joined #RubyOnRails
[11:57:12] DaniG2k: hello all. I have a base controller from which I'd like to dynamically define an attr_reader and a helper_method but I haven't been able to do so properly
[11:57:44] DaniG2k: I basically have a BaseAuditsController and then another class that inherits from it, say TerminalAuditsController < BaseAuditsController
[11:57:58] DaniG2k: and I'd like to dynamically define the attr_reader and helper_method
[11:58:03] DaniG2k: on the base class
[11:58:50] DaniG2k: any idea how I can do so?
[12:06:29] DaniG2k: tbuehlmann: I've explained it here: https://stackoverflow.com/questions/53538622/rails-dynamically-add-attr-reader-and-helper-method-to-a-base-controller
[12:06:57] DaniG2k: tbuehlmann: I've tried with class_eval { attr_reader resource_name.to_sym }
[12:07:51] DaniG2k: and I tried with instance_eval
[12:08:27] DaniG2k: you mean instead of resource_name?
[12:08:29] DaniG2k: yeah same thing
[12:08:38] DaniG2k: it's a name though
[12:08:43] DaniG2k: I get a string
[12:10:18] DaniG2k: oooh I think i get it
[12:10:30] DaniG2k: for the attr_reader I need to do something like
[12:11:00] DaniG2k: define_method resource_name {instance_variable_get "@#{resource_name}"}
[12:11:14] DaniG2k: that would create the reader
[12:13:07] DaniG2k: but we have so many controllers that follow the same exact pattern that if I could jsut do this, we'd eliminate a ton of redundant code
[12:14:27] DaniG2k: simplest would just be to add attr_reader and helper_method on the child
[12:39:07] DaniG2k: does inherited always get called?
[12:39:12] DaniG2k: automatically?
[12:44:44] DaniG2k: base controller is fine
[12:44:48] DaniG2k: thanks, I'll give that a whirl
[12:53:31] DaniG2k: Quit: leaving


[10:44:42] DaniG2k: has joined #RubyOnRails
[10:46:08] DaniG2k: hello all. I have an index on a table that looks like the following: add_index "vessel_plans", ["voyage_id"], name: "index_vessel_plans_on_voyage_id", using: :btree
[10:46:16] DaniG2k: I'd like to change that with the following migration
[10:46:25] DaniG2k: add_index :vessel_plans, %i[status voyage_id], algorithm: :concurrently, unique: true
[10:46:40] DaniG2k: but rake tells me I can't because obviously there's already an index on voyage_id
[10:46:55] DaniG2k: (I'd be adding a uniqueness constraint by doing it using voyage_id and status
[10:47:18] DaniG2k: anyone know how I can remove the last index, create the new one and ensure the previous entries are all indexed?
[10:49:35] DaniG2k: Index name 'index_vessel_plans_on_status_and_voyage_id' on table 'vessel_plans' already exists
[10:49:44] DaniG2k: but it's not true because that index doesn't exist
[10:50:00] DaniG2k: I just have `add_index "vessel_plans", ["voyage_id"], name: "index_vessel_plans_on_voyage_id", using: :btree` right now
[10:53:13] DaniG2k: yep it's in front of me. I've grepped the file for that index but it definitely doesn't exist
[10:54:41] DaniG2k: I am using strong_migrations but that shouldn't make a difference here
[10:59:39] DaniG2k: I was looking at the schema
[10:59:59] DaniG2k: I don't think it would be different from the database
[11:04:21] DaniG2k: interesting, yea. I think postgres creates it
[11:04:24] DaniG2k: index_vessel_plans_on_status_and_voyage_id
[11:04:30] DaniG2k: but Rails doesn't reflect the change
[11:06:10] DaniG2k: I made the migration myself
[11:07:14] DaniG2k: here's my migration file: https://gist.github.com/DaniG2k/83ce2c515108ff13f4960f4b1a78c5f5
[11:07:32] DaniG2k: I'm using strong migrations which is why I have that disable_ddl_transaction!
[11:11:10] DaniG2k: yep I think that's it. The migration failed but probably no rollback
[11:11:21] DaniG2k: might be an issue with strong_migrations
[11:12:03] DaniG2k: maybe I can try without that
[11:13:42] DaniG2k: ah nevermind, the docs say "If you forget disable_ddl_transaction!, the migration will fail."
[11:36:44] DaniG2k: Quit: leaving


[09:09:50] DaniG2k: has joined #RubyOnRails
[09:10:45] DaniG2k: Hello all. I'm trying to add a few lines to every setup and teardown for a number of integration tests (using ActionDispatch::IntegrationTest). I basically want to do DatabaseCleaner.start on every setup and Warden.test_reset!; DatabaseCleaner.clean on every teardown
[09:11:08] DaniG2k: I tried moneky-patching the setup and teardown methods in ActionDispatch::IntegrationTest and then calling super on those
[09:11:34] DaniG2k: but that doesn't seem to work, as I get a NoMethodError: super called outside of method
[09:12:38] DaniG2k: I'm wondering how I can use the same code for every setup and teardown without overriding the more specific setup and teardown within my integration tests
[09:20:26] DaniG2k: I've outlined my problem in a bit more detail on SO: https://stackoverflow.com/questions/52889412/how-to-write-a-base-setup-and-teardown-that-runs-before-every-actiondispatchin
[09:49:22] DaniG2k: Quit: leaving


[14:49:23] DaniG2k: has joined #RubyOnRails
[14:50:14] DaniG2k: hello all. I'm having a hard time doing an ActiveRecord `group()` on a related model. My query is as follows:
[14:50:56] DaniG2k: organization.containers.currently_at('Terminal').joins(:container_type).group('container_types.label')
[14:51:03] DaniG2k: but I get the error message:
[14:51:16] DaniG2k: PG::GroupingError: ERROR: column "containers.id" must appear in the GROUP BY clause or be used in an aggregate function
[15:04:41] DaniG2k: yeah I added `.select('count(containers.id) as total')` but that also failed
[15:06:25] DaniG2k: I'll try with a double group
[15:06:29] DaniG2k: .group('containers.id, container_types.label')
[15:21:16] DaniG2k: Quit: leaving


[11:40:47] DaniG2k: has joined #ruby
[11:40:52] DaniG2k: has joined #RubyOnRails
[11:57:59] DaniG2k: Quit: leaving


[10:29:34] DaniG2k: has joined #ruby
[10:29:38] DaniG2k: has joined #RubyOnRails
[10:30:00] DaniG2k: Client Quit


[10:26:31] DaniG2k: has joined #ruby
[10:26:37] DaniG2k: has joined #RubyOnRails
[10:27:01] DaniG2k: hello all. I'm trying to write an RSpec/Capybara test that checks a redirect when a user visits a page
[10:27:14] DaniG2k: however, the page is external to my app so I don't actually want the test to go there
[10:27:19] DaniG2k: how should I do this?
[10:28:04] DaniG2k: so I have something like visit '/some/path' and I'm trying to expect a redirect to an external website.
[11:50:09] DaniG2k: fox_mulder_cp: I explained my question in a bit more detail on SO
[11:50:13] DaniG2k: https://stackoverflow.com/questions/49171142/rspec-capybara-redirect-to-external-page-sends-me-back-to-root-path
[12:19:17] DaniG2k: Ping timeout: 268 seconds
[12:44:07] DaniG2k: has joined #ruby
[12:51:42] DaniG2k: Quit: leaving
[13:33:02] DaniG2k: has joined #ruby
[13:33:05] DaniG2k: has joined #RubyOnRails
[13:33:33] DaniG2k: hello all. I'm trying to write a Helper spec. However, my locales aren't being passed in
[13:33:38] DaniG2k: how can I pass in the locale in my helpers
[13:46:09] DaniG2k: Ping timeout: 260 seconds
[13:48:10] DaniG2k: has joined #ruby
[13:56:07] DaniG2k: Quit: leaving


[13:36:13] DaniG2k: and so forth
[13:36:23] DaniG2k: so I'm trying to set those routes us
[13:36:40] DaniG2k: Cork: I have something like this now https://gist.github.com/DaniG2k/4a5cd12d105dc09fa0b13298186adfb7
[13:37:12] DaniG2k: there are several problems with this though: 1) it has no root. 2) it only generates one named route (contact_path)
[13:37:27] DaniG2k: this is all kinds of stupid, I know, but this is how the client wants it
[13:40:08] DaniG2k: well, the way I have it now only generates 1 named route, contact_path
[13:40:16] DaniG2k: the others have no name
[13:40:32] DaniG2k: if I do get '/contact', to: 'contacts#index', as: 'contact' then it breaks with ArgumentError: Invalid route name, already in use: 'contact'
[13:40:50] DaniG2k: hmm let me try that
[13:41:08] DaniG2k: so the route shouldn't have an `as`?
[13:42:29] DaniG2k: so if I do contact_path(locale: params[:locale], country: params[:country])
[13:42:36] DaniG2k: No route matches {:action=>"index", :controller=>"contacts", :country=>"IT", :locale=>"it"}, possible unmatched constraints: [:locale]
[13:43:23] DaniG2k: its' in the params, i just checked
[13:43:24] DaniG2k: {"controller"=>"contacts", "action"=>"index", "locale"=>"it", "country"=>"IT"}
[13:44:20] DaniG2k: because the possible languages depend on the locale
[13:45:03] DaniG2k: and how would i define the logic for country on a locale basis
[13:48:37] DaniG2k: whats the diff between scope "/:locale/", locale: LOCALES and scope "/:locale/", constraints: { locale: LOCALES }
[13:56:33] DaniG2k: I'm still confused
[13:56:37] DaniG2k: how to do this
[14:04:47] DaniG2k: Cork: I've created an SO thread cause I can't figure out the proper way to write it :-/
[14:04:50] DaniG2k: https://stackoverflow.com/questions/49132699/rails-5-double-scope-in-routes
[14:04:57] DaniG2k: hopefully someone knows better than myself
[15:03:00] DaniG2k: Quit: leaving
[15:33:05] DaniG2k: has joined #ruby
[15:33:16] DaniG2k: has joined #RubyOnRails
[15:33:28] DaniG2k: I'm trying to get a nested scope like:
[15:33:35] DaniG2k: /:locale/:country/contact
[15:33:43] DaniG2k: but can't do it for the life of me
[15:33:49] DaniG2k: I'm trying with
[15:34:05] DaniG2k: scope "/:locale", /en|it|ja/ do
[15:34:09] DaniG2k: and then another scope within that
[15:34:14] DaniG2k: but it doesn't seem correct
[15:34:17] DaniG2k: I've also tried with
[15:34:24] DaniG2k: scope "/:locale", /en|it|ja/ do
[15:34:35] DaniG2k: get '/:country/contact', to: 'contacts#index', as: 'contact', constraints: { country: MYCONSTRAINT }
[15:34:42] DaniG2k: but that doesn't work either
[15:34:48] DaniG2k: can someone help plz -_-
[15:36:27] DaniG2k: I've created a SO thread
[15:36:28] DaniG2k: https://stackoverflow.com/questions/49132699/rails-5-double-scope-in-routes
[15:42:55] DaniG2k: Quit: leaving