R
Join ServerRailway
✋|help
User index page empty on Railway, works locally and on Heroku
I have no idea why this might be happening, but I'm trying to migrate my Rails 7 app from Heroku to Railway and for some reason the user index page, viewable only by admins, is showing up empty (page loads but no users shown).
There are users in the DB, I can log in and see their show pages, as well as see them in the console.
The code works fine locally, as well as when deployed on Heroku. You can compare local server logs with Railway logs and see that for some reason on Railway it's not getting users.
There are users in the DB, I can log in and see their show pages, as well as see them in the console.
The code works fine locally, as well as when deployed on Heroku. You can compare local server logs with Railway logs and see that for some reason on Railway it's not getting users.
Local logs:
Started GET "/en/users" for ::1 at 2022-11-08 13:38:38 +0200
Processing by UsersController#index as HTML
Parameters: {"locale"=>"en"}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 1], ["LIMIT", 1]]
↳ app/controllers/users_controller.rb:18:in `admin_user'
Rendering layout layouts/application.html.erb
Rendering users/index.html.erb within layouts/application
User Count (0.4ms) SELECT COUNT() FROM "users" WHERE "users"."confirmed" = $1 [["confirmed", true]]
↳ app/views/users/index.html.erb:4
User Load (0.3ms) SELECT "users". FROM "users" WHERE "users"."confirmed" = $1 LIMIT $2 OFFSET $3 [["confirmed", true], ["LIMIT", 30], ["OFFSET", 0]]
↳ app/views/users/index.html.erb:7
Rendered collection of users/_user.html.erb [30 times] (Duration: 4.6ms | Allocations: 3858)
Rendered users/index.html.erb within layouts/application (Duration: 11.0ms | Allocations: 6653)
Rendered layouts/_bootstrap_cdn.html.erb (Duration: 0.0ms | Allocations: 16)
Rendered layouts/_rails_default.html.erb (Duration: 7.3ms | Allocations: 5483)
Rendered layouts/_shim.html.erb (Duration: 0.0ms | Allocations: 15)
Rendered shared/_search_bar.erb (Duration: 0.0ms | Allocations: 24)
Rendered user/_session_manager.html.erb (Duration: 0.5ms | Allocations: 366)
Rendered shared/_search_modal.erb (Duration: 0.6ms | Allocations: 592)
Rendered layouts/_header.html.erb (Duration: 1.8ms | Allocations: 1355)
Rendered layouts/_messages.html.erb (Duration: 0.0ms | Allocations: 27)
Rendered layouts/_footer.html.erb (Duration: 0.5ms | Allocations: 158)
Rendered layout layouts/application.html.erb (Duration: 23.8ms | Allocations: 15919)
Completed 200 OK in 31ms (Views: 23.6ms | ActiveRecord: 1.2ms | Allocations: 17431)
Started GET "/en/users" for ::1 at 2022-11-08 13:38:38 +0200
Processing by UsersController#index as HTML
Parameters: {"locale"=>"en"}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 1], ["LIMIT", 1]]
↳ app/controllers/users_controller.rb:18:in `admin_user'
Rendering layout layouts/application.html.erb
Rendering users/index.html.erb within layouts/application
User Count (0.4ms) SELECT COUNT() FROM "users" WHERE "users"."confirmed" = $1 [["confirmed", true]]
↳ app/views/users/index.html.erb:4
User Load (0.3ms) SELECT "users". FROM "users" WHERE "users"."confirmed" = $1 LIMIT $2 OFFSET $3 [["confirmed", true], ["LIMIT", 30], ["OFFSET", 0]]
↳ app/views/users/index.html.erb:7
Rendered collection of users/_user.html.erb [30 times] (Duration: 4.6ms | Allocations: 3858)
Rendered users/index.html.erb within layouts/application (Duration: 11.0ms | Allocations: 6653)
Rendered layouts/_bootstrap_cdn.html.erb (Duration: 0.0ms | Allocations: 16)
Rendered layouts/_rails_default.html.erb (Duration: 7.3ms | Allocations: 5483)
Rendered layouts/_shim.html.erb (Duration: 0.0ms | Allocations: 15)
Rendered shared/_search_bar.erb (Duration: 0.0ms | Allocations: 24)
Rendered user/_session_manager.html.erb (Duration: 0.5ms | Allocations: 366)
Rendered shared/_search_modal.erb (Duration: 0.6ms | Allocations: 592)
Rendered layouts/_header.html.erb (Duration: 1.8ms | Allocations: 1355)
Rendered layouts/_messages.html.erb (Duration: 0.0ms | Allocations: 27)
Rendered layouts/_footer.html.erb (Duration: 0.5ms | Allocations: 158)
Rendered layout layouts/application.html.erb (Duration: 23.8ms | Allocations: 15919)
Completed 200 OK in 31ms (Views: 23.6ms | ActiveRecord: 1.2ms | Allocations: 17431)
Production server logs:
I, [2022-11-08T11:39:47.740716 #19] INFO -- : [8cc8cc81-a68c-4ae6-80a8-a68b31ae0a34] Started GET "/en/users" for 79.183.112.167 at 2022-11-08 11:39:47 +0000
I, [2022-11-08T11:39:47.741782 #19] INFO -- : [8cc8cc81-a68c-4ae6-80a8-a68b31ae0a34] Processing by UsersController#index as HTML
I, [2022-11-08T11:39:47.741846 #19] INFO -- : [8cc8cc81-a68c-4ae6-80a8-a68b31ae0a34] Parameters: {"locale"=>"en"}
I, [2022-11-08T11:39:47.753841 #19] INFO -- : [8cc8cc81-a68c-4ae6-80a8-a68b31ae0a34] Rendered users/index.html.erb within layouts/application (Duration: 3.9ms | Allocations: 414)
I, [2022-11-08T11:39:47.758103 #19] INFO -- : [8cc8cc81-a68c-4ae6-80a8-a68b31ae0a34] Rendered layout layouts/application.html.erb (Duration: 8.2ms | Allocations: 2537)
I, [2022-11-08T11:39:47.758466 #19] INFO -- : [8cc8cc81-a68c-4ae6-80a8-a68b31ae0a34] Completed 200 OK in 17ms (Views: 6.5ms | ActiveRecord: 4.2ms | Allocations: 3549)
I, [2022-11-08T11:39:47.740716 #19] INFO -- : [8cc8cc81-a68c-4ae6-80a8-a68b31ae0a34] Started GET "/en/users" for 79.183.112.167 at 2022-11-08 11:39:47 +0000
I, [2022-11-08T11:39:47.741782 #19] INFO -- : [8cc8cc81-a68c-4ae6-80a8-a68b31ae0a34] Processing by UsersController#index as HTML
I, [2022-11-08T11:39:47.741846 #19] INFO -- : [8cc8cc81-a68c-4ae6-80a8-a68b31ae0a34] Parameters: {"locale"=>"en"}
I, [2022-11-08T11:39:47.753841 #19] INFO -- : [8cc8cc81-a68c-4ae6-80a8-a68b31ae0a34] Rendered users/index.html.erb within layouts/application (Duration: 3.9ms | Allocations: 414)
I, [2022-11-08T11:39:47.758103 #19] INFO -- : [8cc8cc81-a68c-4ae6-80a8-a68b31ae0a34] Rendered layout layouts/application.html.erb (Duration: 8.2ms | Allocations: 2537)
I, [2022-11-08T11:39:47.758466 #19] INFO -- : [8cc8cc81-a68c-4ae6-80a8-a68b31ae0a34] Completed 200 OK in 17ms (Views: 6.5ms | ActiveRecord: 4.2ms | Allocations: 3549)
Hey there!
Can you enable - RAILS_SERVE_STATIC_FILES to true in the service variables pane?
Can you enable - RAILS_SERVE_STATIC_FILES to true in the service variables pane?
also tagging in @Cereal who is more familiar with Rails on Railway than I
3 Messages Not Public
Sign In & Join Server To View
Pinging @beccamay
contollers/users_controller.rb
class UsersController < ApplicationController
before_action :authenticate_user!, only: :show
before_action :admin_user, :only => [:index, :edit, :update, :destroy]
def show
@user = User.find(params[:id])
end
def index
@users = User.where(confirmed: true).paginate(page:params[:page])
end
private
def admin_user
redirect_to(root_url, status: :see_other) unless
current_user && current_user.admin?
end
end
tip, you can make it syntax highlighted by using `
I will show ya
And here's the view, as you can see nothing crazy...
views/users/index.html.erb
views/users/_user.html.erb
views/users/index.html.erb
<% provide(:title, 'All users') %>
<h2>All users</h2>
<%= will_paginate(@users) %>
<ul class="users">
<%= render @users %>
</ul>
<%= will_paginate(@users) %>
views/users/_user.html.erb
<li>
<%= gravatar_for user, size: 50 %>
<%= link_to user.name, user %>
</li>
class UsersController < ApplicationController
before_action :authenticate_user!, only: :show
before_action :admin_user, :only => [:index, :edit, :update, :destroy]
def show
@user = User.find(params[:id])
end
def index
@users = User.where(confirmed: true).paginate(page:params[:page])
end
private
def admin_user
redirect_to(root_url, status: :see_other) unless
current_user && current_user.admin?
end
end
three backticks, and then language
thanks i'm not sure how to make it colored though? i used three backticks
you have to add the language after the three backticks
so
ruby
in this caseRAILS_SERVE_STATIC_FILES is enabled
I am unsure that
erb
works.awesome thanks for the tip! syntax highlighting added. now let's see if you can help me with the user index, really can't understand what's going on 😦
One last thing, Project ID?
(cmd + k/ctrl + k) -> project id'
that way I can look into your logs
Is project ID sensitive?
wdym
its a UUID
not like a password or anything, no other user can do anything with that information
ok thanks - 83791c3c-35a4-439c-96ea-34c41b9aed33
looking
Unrelated: You really shouldn't be using the Heroku buildpacks, those are going away in a week
I am looking into why that build is failing in the first place
Uh oh, thanks for the heads up. Can you point me to resources what to use instead of Heroku buildpacks? I am new at this so if there's a walkthrough doc somewhere that would be great
Gotcha- we actually have a community member working on a Rails walkthrough doc haha
I am not a Rails dev but used to be one, so I can work my way through Ruby
also, I notice that a lot of Rails dev are having issues on here, so REALLY committed to fixing that experience
Can you do me a favor, slam through another
railway up
in your terminal?Good to hear. It's been rough trying to migrate from Heroku last couple weeks, I'm trying to make it work but so many issues
I can understand that frustration, very sorry.
Lets get you on some good footing.
did it
lmk when you have kicked this off.
cool, looking
build failed
expected, debugging
strange its complaining about:
#9 4.067 E: Unable to locate package libimagemagick-dev
but you have the right vars
Roping in another eng
appreciate it
can you add a file called
nixpacks.toml
with the contents:[phases.install]
cmds = ['apt install -y libmagickwand-dev']
then slam a
up
afterto the top level of the project?
yes
It seems to be an issue with Imagemagick and the package deps it needs
(for builds)
then I think this would solve the other issue too
Because another usr reported an issue with the other buildpack messing with the templates, but this is a guess
added
cool watching
var conflict, fixing
Okay, taking longer, this is good
hehe
anything different is good...
yep, totally fresh install
even if this makes the build succeed, I don't see how this would relate to the users index. I'm not doing any image processing there
ok let's see
still empty
ok
lets see
still looking
so for some reason, it can't find these Gems, thats why its triggering the error
#18 0.834 /usr/local/rvm/gems/ruby-3.1.2/gems/bundler-2.3.14/lib/bundler/definition.rb:486:in `materialize': Could not find active_storage_validations-1.0.3, aws-sdk-s3-1.116.0, bootsnap-1.12.0, bootstrap-sass-3.4.1, bootstrap-will_paginate-1.0.0, devise-4.8.1, geocoder-1.8.0, image_processing-1.12.2, importmap-rails-1.1.0, jbuilder-2.11.5, jsonapi-serializer-2.2.0, pg-1.4.4, puma-5.6.4, rails-7.0.3, rails-i18n-7.0.5, ransack-3.2.1, sprockets-rails-3.4.2, stimulus-rails-1.0.4, turbo-rails-1.1.1, will_paginate-3.3.1, debug-1.5.0, faker-2.20.0, web-console-4.2.0, capybara-3.37.1, selenium-webdriver-4.2.0, webdrivers-5.0.0, rails-controller-testing-1.0.5, minitest-reporters-1.5.0, guard-2.18.0, guard-minitest-2.4.6, activejob-7.0.3, activemodel-7.0.3, activestorage-7.0.3, activesupport-7.0.3, aws-sdk-core-3.164.0, aws-sdk-kms-1.58.0, aws-sigv4-1.5.2, msgpack-1.5.2, autoprefixer-rails-10.4.7.0, sassc-2.4.0, bcrypt-3.1.18, orm_adapter-0.5.0, railties-7.0.3, responders-3.0.1, warden-1.2.9, mini_magick-4.11.0, ruby-vips-2.1.4, actionpack-7.0.3, actionview-7.0.3, nio4r-2.5.8, actioncable-7.0.3, actionmailbox-7.0.3, actionmailer-7.0.3, actiontext-7.0.3, activerecord-7.0.3, i18n-1.10.0, sprockets-4.0.3, reline-0.3.1, bindex-0.8.1, addressable-2.8.0, mini_mime-1.1.2, nokogiri-1.13.6-x86_64-linux, rack-2.2.3.1, rack-test-1.1.0, regexp_parser-2.5.0, xpath-3.2.0, childprocess-4.1.0, rubyzip-2.3.2, websocket-1.2.9, ansi-1.5.0, builder-3.2.4, ruby-progressbar-1.11.0, formatador-1.1.0, listen-3.7.1, lumberjack-1.2.8, nenv-0.3.0, notiffany-0.1.3, pry-0.14.1, shellany-0.0.1, thor-1.2.1, guard-compat-1.2.1, globalid-1.0.0, marcel-1.0.2, concurrent-ruby-1.1.10, tzinfo-2.0.4, aws-eventstream-1.2.0, aws-partitions-1.649.0, jmespath-1.6.1, execjs-2.8.1, ffi-1.15.5, method_source-1.0.0, zeitwerk-2.6.0, rails-dom-testing-2.0.3, rails-html-sanitizer-1.4.3, erubi-1.10.0, websocket-driver-0.7.5, mail-2.7.1, public_suffix-4.0.7, rb-fsevent-0.11.1, rb-inotify-0.10.1, coderay-1.1.3, loofah-2.18.0, websocket-extensions-0.1.5, net-protocol-0.1.3, strscan-3.0.3, timeout-0.3.0, crass-1.0.6 in any of the sources (Bundler::GemNotFound)
Working with our Nixpacks eng, one sec
also tagging someone who might know
cc @wyzlle
Found a typo in the gemfile, updating and deploying again
Message Not Public
Sign In & Join Server To View
Hi
Now for some reason it's installing ruby and doing a whole lot of stuff it didn't in previous deploys.
Message Not Public
Sign In & Join Server To View
same issue
#18 ERROR: executor failed running [/bin/bash -ol pipefail -c bundle exec rake assets:precompile]: exit code: 1
-----
> [stage-0 14/15] RUN bundle exec rake assets:precompile:
-----
executor failed running [/bin/bash -ol pipefail -c bundle exec rake assets:precompile]: exit code: 1
Error: Docker build failed
We have a hunch on what it might be.
going to switch ya back to Heroku stuff just so we can fix issue #1 :'P
At least we caught this.
Re-building
!
! There was an error parsing your Gemfile, we cannot continue
!
! [!] There was an error parsing `Gemfile`: syntax error, unexpected string literal, expecting `do' or '{' or '(' - gem "aws-sdk-s3", r...
! ^
! /workspace/Gemfile:7: syntax error, unexpected ',', expecting end-of-input
! gem "aws-sdk-s3", require: false
! ^
! . Bundler cannot continue.
!
! # from /workspace/Gemfile:7
! # -------------------------------------------
! # gem "active_storage_validations",
! > gem "aws-sdk-s3", require: false
! # gem "bootsnap", "1.12.0", require: false
! # -------------------------------------------
One second reverting that change
deployed again with gemfile fixed
Message Not Public
Sign In & Join Server To View
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 3.3.7
- RUBY VERSION: 3.1.2 (2022-04-12 patchlevel 20) [arm64-darwin21]
- INSTALLATION DIRECTORY: /Users/rebeccamaybaum/.rvm/gems/ruby-3.1.2
- USER INSTALLATION DIRECTORY: /Users/rebeccamaybaum/.gem/ruby/3.1.0
- RUBY EXECUTABLE: /Users/rebeccamaybaum/.rvm/rubies/ruby-3.1.2/bin/ruby
- GIT EXECUTABLE: /opt/homebrew/bin/git
- EXECUTABLE DIRECTORY: /Users/rebeccamaybaum/.rvm/gems/ruby-3.1.2/bin
- SPEC CACHE DIRECTORY: /Users/rebeccamaybaum/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/rebeccamaybaum/.rvm/rubies/ruby-3.1.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- arm64-darwin-21
- GEM PATHS:
- /Users/rebeccamaybaum/.rvm/gems/ruby-3.1.2
- /Users/rebeccamaybaum/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/rebeccamaybaum/.rvm/gems/ruby-3.1.2/bin
- /Users/rebeccamaybaum/.rvm/gems/ruby-3.1.2@global/bin
- /Users/rebeccamaybaum/.rvm/rubies/ruby-3.1.2/bin
- /Users/rebeccamaybaum/.rvm/bin
- /usr/local/bin
- /opt/homebrew/bin
- /opt/homebrew/sbin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
Good news that the latest build succeeded. Bad news that the original issue is still happening :/
Lets fix that now
Honestly I actually think now the more urgent issue is moving from Heroku buildpacks... I will keep working on the user index issue but if buildpacks are gone next week that's bigger
I don't know how to convert to nixpacks
When do you think the documentation will be ready for that?
Well, it should just be slot in
so the issue is on our end
luckily we have Jr working on that now
Meaning Nixpacks should be slot in?
Yes