Ejabberd / Rails "getaddrinfo: nodename nor servname provided, or not known" - ruby-on-rails

I get the error
SocketError in UsersController#create
getaddrinfo: nodename nor servname provided, or not known
When i try to crate an account in my rails app. I think that the issue relates either to ejabberd or action mailer. How can I find out more about where this error comes from?
Here is def create in my users_controller
def create
#user = User.new(params[:user])
if #user.save!
clear_current_session
MailAgent.registration_confirmation(#user).deliver
flash[:notice] = 'Please activate your account by clicking on the link sent to you by email.'
redirect_to new_user_url
else
flash.now[:error] = 'Please fix the listed errors'
render 'new'
end
end
Here is the full error
Started GET "/" for 127.0.0.1 at 2011-08-02 10:18:33 +1000
Processing by PagesController#home as HTML
Redirected to http://localhost:3000/users/new
Completed 302 Found in 0ms
Started GET "/users/new" for 127.0.0.1 at 2011-08-02 10:18:33 +1000
Processing by UsersController#new as HTML
Rendered users/_signup_form.html.erb (6.5ms)
Rendered layouts/_login_links.html.erb (23.3ms)
Rendered layouts/_error_messages.html.erb (0.3ms)
Rendered users/new.html.erb within layouts/application (33.7ms)
Completed 200 OK in 36ms (Views: 35.6ms | ActiveRecord: 0.2ms)
Started POST "/users" for 127.0.0.1 at 2011-08-02 10:18:49 +1000
Processing by UsersController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"0JgPvOiu18OjD6TmpUrxDGtPiTUBlw0W78HqtdV/brc=", "user"=>{"name"=>"test", "email"=>"[FILTERED]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign Up"}
[1m[36mSQL (0.1ms)[0m [1mBEGIN[0m
[1m[35mUser Load (0.1ms)[0m SELECT `users`.`id` FROM `users` WHERE (LOWER(`users`.`email`) = LOWER("[FILTERED]")) LIMIT 1
[1m[36mUser Load (0.1ms)[0m [1mSELECT `users`.`id` FROM `users` WHERE (`users`.`persistence_token` = BINARY '61b972eee6ed6eb2341b08d92640b08e6379b8743a4df5aa73a233151a6d5629896470e00e108d0f08d20814fb67d8') LIMIT 1[0m
[1m[35mSQL (1.7ms)[0m describe `users`
[1m[36mAREL (0.2ms)[0m [1mINSERT INTO `users` (`name`, `email`, `crypted_password`, `password_salt`, `persistence_token`, `perishable_token`, `login_count`, `last_login_at`, `created_at`, `updated_at`, `activated`) VALUES ('test', "[FILTERED]", '37712237698ea6db7f044f9408adee9d1fe02447bdb1b92c34b71d2ca35795dd04af1528aa73b6e7db5b11f', 'JnajFzu5luNXbeU', '61b972ec6e0ee6ed6eb08e6379b8743a448ced73ddf5aa73a233151a6d56298e53a996470e00e108d0f08d20814f9c461185f0b67d8', 'bIPlmXIFPjJDHzt', 1, NULL, '2011-08-02 00:18:49', '2011-08-02 00:18:49', 0)[0m
[1m[35mJabberCredential Load (0.1ms)[0m SELECT `jabber_credentials`.* FROM `jabber_credentials` WHERE (`jabber_credentials`.user_id = 12) LIMIT 1
[1m[36mJabberCredential Load (0.1ms)[0m [1mSELECT `jabber_credentials`.`id` FROM `jabber_credentials` WHERE (`jabber_credentials`.`jabber_id` = BINARY '12_test_72') LIMIT 1[0m
[1m[35mSQL (1.3ms)[0m describe `jabber_credentials`
[1m[36mAREL (0.1ms)[0m [1mINSERT INTO `jabber_credentials` (`jabber_id`, `jabber_password`, `user_id`, `created_at`, `updated_at`) VALUES ('12_test_72', '123456', 12, '2011-08-02 00:18:49', '2011-08-02 00:18:49')[0m
[1m[35mSQL (0.5ms)[0m ROLLBACK
Completed in 32093ms
SocketError (getaddrinfo: nodename nor servname provided, or not known):
lib/xmpp_client.rb:14:in `initialize'
app/models/user.rb:27:in `new'
app/models/user.rb:27:in `register_jabber'
app/models/user_observer.rb:7:in `after_create'
app/controllers/users_controller.rb:11:in `create'
Rendered /Users/fred/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.6ms)
Rendered /Users/fred/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.4ms)
Rendered /Users/fred/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (4.8ms)

Check your log file, whenever an exception is thrown it outputs the stack trace. Lines closest to the top are more relevant than those lower down. Many of the lines will be "false errors" meaning they are not the problem, but fail because of the problem. It takes some guess-work and a healthy dose of experience to figure out which one is relevant.
Please include the stack trace and maybe we can help you further.

Related

Debug RailsAdmin error which causes transaction rollback

I'm trying to solve a current issue on my rails app. My rails app is using RailsAdmin and I have an issue after trying to upload files via generic RailsAdmin options.
So this app is using Ruby 2.5.3, RailsAdmin 1.4.2 and Rails 5.2.3.
It seems that I'm running in a silent error ... maybe a kind of model validation or something like that buy I even don't get any relevant output on debug mode.
The problem is that I have no certain idea how I should proceed on debugging this problem because these actions are handled within the rails-admin gem.
Even though I'm using RubyMine with the debugging feature I have no clue where to set the breakpoints because this is handled be the gem. I've tried to break on some initializers but of course that didn't had the intended effect.
So I would appreciate any hints and help which supports me debugging this problem!
Best regards,
Tunnelblick
Debug output:
Started POST "/administrator/document/new" for <src_ip> at 2019-09-03 11:47:46 +0200
Processing by RailsAdmin::MainController#new as JS
Parameters: {"utf8"=>"✓", "authenticity_token"=>"<token>", "document"=>{"title"=>"Testimage", "description"=>"", "page_ids"=>["", "", "151"], "file"=>#<ActionDispatch::Http::UploadedFile:0x00007f4ebbf196e8 #tempfile=#<Tempfile:/tmp/RackMultipart20190903-3614-gbt3ad.png>, #original_filename="generic_testimage.png", #content_type="image/png", #headers="Content-Disposition: form-data; name=\"document[file]\"; filename=\"generic_testimage.png\"\r\nContent-Type: image/png\r\n">}, "remotipart_submitted"=>"true", "X-Requested-With"=>"IFrame", "X-HTTP-Accept"=>"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01", "model_name"=>"document"}
User Load (0.7ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
↳ config/initializers/rails_admin.rb:97
(0.9ms) SELECT `user_roles`.`role_id` FROM `user_roles` WHERE `user_roles`.`user_id` = 1
↳ app/models/user.rb:236
(0.5ms) SELECT `roles`.`name` FROM `roles` WHERE `roles`.`id` = 1
↳ app/models/user.rb:236
Disk Storage (4.5ms) Uploaded file to key: HsSaBijYwg3JLeR8dV7akmpF (checksum: /QSj27UArM/yWCLulQaTpA==)
(0.3ms) BEGIN
↳ /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/bundler/gems/activerecord-sqlserver-adapter-1105d02d6284/lib/active_record/connection_adapters/sqlserver/transaction.rb:38
ActiveStorage::Blob Create (0.6ms) INSERT INTO `active_storage_blobs` (`key`, `filename`, `content_type`, `metadata`, `byte_size`, `checksum`, `created_at`) VALUES ('HsSaBijYwg3JLeR8dV7akmpF', 'generic_testimage.png', 'image/png', '{\"identified\":true}', 2673, '/QSj27UArM/yWCLulQaTpA==', '2019-09-03 09:47:46')
↳ /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98
(3.6ms) COMMIT
↳ /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/bundler/gems/activerecord-sqlserver-adapter-1105d02d6284/lib/active_record/connection_adapters/sqlserver/transaction.rb:42
(0.3ms) BEGIN
↳ /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/bundler/gems/activerecord-sqlserver-adapter-1105d02d6284/lib/active_record/connection_adapters/sqlserver/transaction.rb:38
(0.4ms) COMMIT
↳ /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/bundler/gems/activerecord-sqlserver-adapter-1105d02d6284/lib/active_record/connection_adapters/sqlserver/transaction.rb:42
Page Load (0.5ms) SELECT `pages`.* FROM `pages` WHERE `pages`.`id` = 151
↳ /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98
(0.3ms) BEGIN
↳ /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/bundler/gems/activerecord-sqlserver-adapter-1105d02d6284/lib/active_record/connection_adapters/sqlserver/transaction.rb:38
(0.2ms) ROLLBACK
↳ /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/bundler/gems/activerecord-sqlserver-adapter-1105d02d6284/lib/active_record/connection_adapters/sqlserver/transaction.rb:47
Rendering /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/gems/rails_admin-1.4.2/app/views/rails_admin/main/new.html.haml
Rendered /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/gems/rails_admin-1.4.2/app/views/rails_admin/main/_form_field.html.haml (3.9ms)
Rendered /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/gems/rails_admin-1.4.2/app/views/rails_admin/main/_form_text.html.haml (3.6ms)
Rendered /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/gems/rails_admin-1.4.2/app/views/rails_admin/main/_form_file_upload.html.haml (7.8ms)
(0.5ms) SELECT COUNT(*) FROM `pages`
↳ /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98
CACHE (0.0ms) SELECT COUNT(*) FROM `pages`
↳ /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98
Rendered /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/gems/rails_admin-1.4.2/app/views/rails_admin/main/_form_filtering_multiselect.html.haml (15.9ms)
Rendered /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/gems/rails_admin-1.4.2/app/views/rails_admin/main/_submit_buttons.html.haml (14.2ms)
Rendered /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/gems/rails_admin-1.4.2/app/views/rails_admin/main/new.html.haml (70.9ms)
Completed 406 Not Acceptable in 124ms (Views: 76.5ms | ActiveRecord: 8.8ms)
<src_ip> - - [03/Sep/2019:11:47:46 CEST] "POST /administrator/document/new HTTP/1.1" 406 5828
http://<dst_ip>:3000/administrator/Page/151/edit -> /administrator/document/new
Started GET "/rails/active_storage/representations/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBb1VEIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--01b687f90aa49f3bfd52fe06cfb950eef8711461/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCam9MY21WemFYcGxTU0lOTVRBd2VERXdNRDRHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6InZhcmlhdGlvbiJ9fQ==--597b84b3c8f143e08ed73e02d88e0aee694d1066/generic_testimage.png" for <src_ip> at 2019-09-03 11:47:46 +0200
Processing by ActiveStorage::RepresentationsController#show as PNG
Parameters: {"signed_blob_id"=>"eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBb1VEIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--01b687f90aa49f3bfd52fe06cfb950eef8711461", "variation_key"=>"eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCam9MY21WemFYcGxTU0lOTVRBd2VERXdNRDRHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6InZhcmlhdGlvbiJ9fQ==--597b84b3c8f143e08ed73e02d88e0aee694d1066", "filename"=>"generic_testimage"}
ActiveStorage::Blob Load (2.5ms) SELECT `active_storage_blobs`.* FROM `active_storage_blobs` WHERE `active_storage_blobs`.`id` = 901 LIMIT 1
↳ /home/testvm01/.rvm/gems/ruby-2.5.3#<gemset>/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98
Disk Storage (0.1ms) Checked if file exists at key: variants/HsSaBijYwg3JLeR8dV7akmpF/64ff10e27609a8b1f320398d41a1f5791aeb2e108f429b203d5f3c650e0b744d (no)
Disk Storage (0.1ms) Downloaded file from key: HsSaBijYwg3JLeR8dV7akmpF
Disk Storage (0.3ms) Uploaded file to key: variants/HsSaBijYwg3JLeR8dV7akmpF/64ff10e27609a8b1f320398d41a1f5791aeb2e108f429b203d5f3c650e0b744d
Disk Storage (0.8ms) Generated URL for file at key: variants/HsSaBijYwg3JLeR8dV7akmpF/64ff10e27609a8b1f320398d41a1f5791aeb2e108f429b203d5f3c650e0b744d (http://<dst_ip>:3000/rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdDRG9JYTJWNVNTSm5kbUZ5YVdGdWRITXZTSE5UWVVKcGFsbDNaek5LVEdWU09HUldOMkZyYlhCR0x6WTBabVl4TUdVeU56WXdPV0U0WWpGbU16SXdNems0WkRReFlURm1OVGM1TVdGbFlqSmxNVEE0WmpReU9XSXlNRE5rTldZell6WTFNR1V3WWpjME5HUUdPZ1pGVkRvUVpHbHpjRzl6YVhScGIyNUpJbFZwYm14cGJtVTdJR1pwYkdWdVlXMWxQU0puWlc1bGNtbGpYM1JsYzNScGJXRm5aUzV3Ym1jaU95Qm1hV3hsYm1GdFpTbzlWVlJHTFRnbkoyZGxibVZ5YVdOZmRHVnpkR2x0WVdkbExuQnVad1k3QmxRNkVXTnZiblJsYm5SZmRIbHdaVWtpRG1sdFlXZGxMM0J1WndZN0JsUT0iLCJleHAiOiIyMDE5LTA5LTAzVDA5OjUyOjQ2LjU4NVoiLCJwdXIiOiJibG9iX2tleSJ9fQ==--c5bcf6d4ef2e2800968e21be38b234711a8d43a9/generic_testimage.png?content_type=image%2Fpng&disposition=inline%3B+filename%3D%22generic_testimage.png%22%3B+filename%2A%3DUTF-8%27%27generic_testimage.png)
Redirected to http://<dst_ip>:3000/rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdDRG9JYTJWNVNTSm5kbUZ5YVdGdWRITXZTSE5UWVVKcGFsbDNaek5LVEdWU09HUldOMkZyYlhCR0x6WTBabVl4TUdVeU56WXdPV0U0WWpGbU16SXdNems0WkRReFlURm1OVGM1TVdGbFlqSmxNVEE0WmpReU9XSXlNRE5rTldZell6WTFNR1V3WWpjME5HUUdPZ1pGVkRvUVpHbHpjRzl6YVhScGIyNUpJbFZwYm14cGJtVTdJR1pwYkdWdVlXMWxQU0puWlc1bGNtbGpYM1JsYzNScGJXRm5aUzV3Ym1jaU95Qm1hV3hsYm1GdFpTbzlWVlJHTFRnbkoyZGxibVZ5YVdOZmRHVnpkR2x0WVdkbExuQnVad1k3QmxRNkVXTnZiblJsYm5SZmRIbHdaVWtpRG1sdFlXZGxMM0J1WndZN0JsUT0iLCJleHAiOiIyMDE5LTA5LTAzVDA5OjUyOjQ2LjU4NVoiLCJwdXIiOiJibG9iX2tleSJ9fQ==--c5bcf6d4ef2e2800968e21be38b234711a8d43a9/generic_testimage.png?content_type=image%2Fpng&disposition=inline%3B+filename%3D%22generic_testimage.png%22%3B+filename%2A%3DUTF-8%27%27generic_testimage.png
Completed 302 Found in 72ms (ActiveRecord: 2.5ms)
<src_ip> - - [03/Sep/2019:11:47:46 CEST] "GET /rails/active_storage/representations/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBb1VEIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--01b687f90aa49f3bfd52fe06cfb950eef8711461/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCam9MY21WemFYcGxTU0lOTVRBd2VERXdNRDRHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6InZhcmlhdGlvbiJ9fQ==--597b84b3c8f143e08ed73e02d88e0aee694d1066/generic_testimage.png HTTP/1.1" 302 863
http://<dst_ip>:3000/administrator/Page/151/edit -> /rails/active_storage/representations/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBb1VEIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--01b687f90aa49f3bfd52fe06cfb950eef8711461/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCam9MY21WemFYcGxTU0lOTVRBd2VERXdNRDRHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6InZhcmlhdGlvbiJ9fQ==--597b84b3c8f143e08ed73e02d88e0aee694d1066/generic_testimage.png
Started GET "/rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdDRG9JYTJWNVNTSm5kbUZ5YVdGdWRITXZTSE5UWVVKcGFsbDNaek5LVEdWU09HUldOMkZyYlhCR0x6WTBabVl4TUdVeU56WXdPV0U0WWpGbU16SXdNems0WkRReFlURm1OVGM1TVdGbFlqSmxNVEE0WmpReU9XSXlNRE5rTldZell6WTFNR1V3WWpjME5HUUdPZ1pGVkRvUVpHbHpjRzl6YVhScGIyNUpJbFZwYm14cGJtVTdJR1pwYkdWdVlXMWxQU0puWlc1bGNtbGpYM1JsYzNScGJXRm5aUzV3Ym1jaU95Qm1hV3hsYm1GdFpTbzlWVlJHTFRnbkoyZGxibVZ5YVdOZmRHVnpkR2x0WVdkbExuQnVad1k3QmxRNkVXTnZiblJsYm5SZmRIbHdaVWtpRG1sdFlXZGxMM0J1WndZN0JsUT0iLCJleHAiOiIyMDE5LTA5LTAzVDA5OjUyOjQ2LjU4NVoiLCJwdXIiOiJibG9iX2tleSJ9fQ==--c5bcf6d4ef2e2800968e21be38b234711a8d43a9/generic_testimage.png?content_type=image%2Fpng&disposition=inline%3B+filename%3D%22generic_testimage.png%22%3B+filename%2A%3DUTF-8%27%27generic_testimage.png" for <src_ip> at 2019-09-03 11:47:46 +0200
Processing by ActiveStorage::DiskController#show as PNG
Parameters: {"content_type"=>"image/png", "disposition"=>"inline; filename=\"generic_testimage.png\"; filename*=UTF-8''generic_testimage.png", "encoded_key"=>"eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdDRG9JYTJWNVNTSm5kbUZ5YVdGdWRITXZTSE5UWVVKcGFsbDNaek5LVEdWU09HUldOMkZyYlhCR0x6WTBabVl4TUdVeU56WXdPV0U0WWpGbU16SXdNems0WkRReFlURm1OVGM1TVdGbFlqSmxNVEE0WmpReU9XSXlNRE5rTldZell6WTFNR1V3WWpjME5HUUdPZ1pGVkRvUVpHbHpjRzl6YVhScGIyNUpJbFZwYm14cGJtVTdJR1pwYkdWdVlXMWxQU0puWlc1bGNtbGpYM1JsYzNScGJXRm5aUzV3Ym1jaU95Qm1hV3hsYm1GdFpTbzlWVlJHTFRnbkoyZGxibVZ5YVdOZmRHVnpkR2x0WVdkbExuQnVad1k3QmxRNkVXTnZiblJsYm5SZmRIbHdaVWtpRG1sdFlXZGxMM0J1WndZN0JsUT0iLCJleHAiOiIyMDE5LTA5LTAzVDA5OjUyOjQ2LjU4NVoiLCJwdXIiOiJibG9iX2tleSJ9fQ==--c5bcf6d4ef2e2800968e21be38b234711a8d43a9", "filename"=>"generic_testimage"}
Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
<src_ip> - - [03/Sep/2019:11:47:46 CEST] "GET /rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdDRG9JYTJWNVNTSm5kbUZ5YVdGdWRITXZTSE5UWVVKcGFsbDNaek5LVEdWU09HUldOMkZyYlhCR0x6WTBabVl4TUdVeU56WXdPV0U0WWpGbU16SXdNems0WkRReFlURm1OVGM1TVdGbFlqSmxNVEE0WmpReU9XSXlNRE5rTldZell6WTFNR1V3WWpjME5HUUdPZ1pGVkRvUVpHbHpjRzl6YVhScGIyNUpJbFZwYm14cGJtVTdJR1pwYkdWdVlXMWxQU0puWlc1bGNtbGpYM1JsYzNScGJXRm5aUzV3Ym1jaU95Qm1hV3hsYm1GdFpTbzlWVlJHTFRnbkoyZGxibVZ5YVdOZmRHVnpkR2x0WVdkbExuQnVad1k3QmxRNkVXTnZiblJsYm5SZmRIbHdaVWtpRG1sdFlXZGxMM0J1WndZN0JsUT0iLCJleHAiOiIyMDE5LTA5LTAzVDA5OjUyOjQ2LjU4NVoiLCJwdXIiOiJibG9iX2tleSJ9fQ==--c5bcf6d4ef2e2800968e21be38b234711a8d43a9/generic_testimage.png?content_type=image%2Fpng&disposition=inline%3B+filename%3D%22generic_testimage.png%22%3B+filename%2A%3DUTF-8%27%27generic_testimage.png HTTP/1.1" 200 830
http://<dst_ip>:3000/administrator/Page/151/edit -> /rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdDRG9JYTJWNVNTSm5kbUZ5YVdGdWRITXZTSE5UWVVKcGFsbDNaek5LVEdWU09HUldOMkZyYlhCR0x6WTBabVl4TUdVeU56WXdPV0U0WWpGbU16SXdNems0WkRReFlURm1OVGM1TVdGbFlqSmxNVEE0WmpReU9XSXlNRE5rTldZell6WTFNR1V3WWpjME5HUUdPZ1pGVkRvUVpHbHpjRzl6YVhScGIyNUpJbFZwYm14cGJtVTdJR1pwYkdWdVlXMWxQU0puWlc1bGNtbGpYM1JsYzNScGJXRm5aUzV3Ym1jaU95Qm1hV3hsYm1GdFpTbzlWVlJHTFRnbkoyZGxibVZ5YVdOZmRHVnpkR2x0WVdkbExuQnVad1k3QmxRNkVXTnZiblJsYm5SZmRIbHdaVWtpRG1sdFlXZGxMM0J1WndZN0JsUT0iLCJleHAiOiIyMDE5LTA5LTAzVDA5OjUyOjQ2LjU4NVoiLCJwdXIiOiJibG9iX2tleSJ9fQ==--c5bcf6d4ef2e2800968e21be38b234711a8d43a9/generic_testimage.png?content_type=image%2Fpng&disposition=inline%3B+filename%3D%22generic_testimage.png%22%3B+filename%2A%3DUTF-8%27%27generic_testimage.png
RailsAdmin MainController
RailsAdmin::Config::Actions.all.each do |action|
class_eval <<-EOS, __FILE__, __LINE__ + 1
def #{action.action_name}
action = RailsAdmin::Config::Actions.find('#{action.action_name}'.to_sym)
#authorization_adapter.try(:authorize, action.authorization_key, #abstract_model, #object)
#action = action.with({controller: self, abstract_model: #abstract_model, object: #object})
fail(ActionNotAllowed) unless #action.enabled?
#page_name = wording_for(:title)
instance_eval &#action.controller
end
EOS
end

Why is my rails app showing a blank page?

I am going though Michael Hartl's rails Tutorial chapter 10 section 10.2. And my rails app is now showing a blank page for all pages I try to load on the local host. I have tried resetting the computer as suggested in another post, but this didn't work. I have checked the development log and here is the error message.
Started GET "/users/3" for 95.10.6.124 at 2017-11-05 16:36:43 +0000
Cannot render console from 95.10.6.124! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by UsersController#show as HTML
Parameters: {"id"=>"3"}
[1m[36mUser Load (0.2ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ?[0m [["id", 3], ["LIMIT", 1]]
Rendering users/show.html.erb within layouts/application
Rendered users/show.html.erb within layouts/application (1.7ms)
Rendered layouts/_rails_default.html.erb (27.1ms)
Rendered layouts/_shim.html.erb (0.5ms)
[1m[36mUser Load (0.2ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ?[0m [["id", 3], ["LIMIT", 1]]
Rendered layouts/_header.html.erb (2.3ms)
Rendered layouts/_footer.html.erb (0.5ms)
Completed 200 OK in 41ms (Views: 38.0ms | ActiveRecord: 0.4ms)
This is strange as I undid the changes I made and now it doesnt work. In fact the serve doesnt seem to start. Instead of seeing the usual "ctrl+c to stop" at the end, the command prompt appears. This hasnt happened before and to my mnowledge I havent done anything differently.
Could someone help me with this, thanks.

Why does my Capybara feature test intermittently fail when waiting for Ajax?

I'm using Capybara 2.13.0 and I've got a test that relies on an Ajax request adding dynamic content into the DOM.
test 'contact data becomes visible when providing the correct password' do
login_as_researcher
visit '/participants/3'
assert page.has_css?("ul#redacted-contact-data")
click_button('Unlock Contact Data')
# Use the correct password
fill_in('enter your password', with: 'password1')
# Ajax happens here. It renders a partial and places it in the dom.
click_button('Submit')
# Test sometimes fails here..
assert page.has_css?("ul#contact-data"), -> { page.body }
end
I've read a lot of articles that say Capybara automatically waits for elements to appear in the HTML and there's no need to manually tell Capybara to wait anymore, but I'm not experiencing this in my case.
75% of the time this test passes and when it does fail and the page is dumped, it contains the content of the partial rendered in the JS response instead of the full HTML page.
Any idea what's going on here? I can only assume it's due to how long it takes the server to respond the Ajax request each time and Capybara not waiting long enough in certain situations.
I've set Capybara.default_max_wait_time = 5 in my test_helper.
I've tried with both the selenium and poltergeist drivers and it makes no difference.
Here's the output from test.log
Started GET "/" for 127.0.0.1 at 2017-05-01 18:09:23 +0100
Processing by HomeController#index as HTML
Researcher Load (0.3ms) SELECT "researchers".* FROM "researchers" WHERE "researchers"."id" IS NULL LIMIT 1
Redirected to http://www.example.com/session/new
Filter chain halted as :researcher_only rendered or redirected
Completed 302 Found in 30ms (ActiveRecord: 0.3ms)
Started GET "/session/new" for 127.0.0.1 at 2017-05-01 18:09:23 +0100
Processing by SessionsController#new as HTML
Rendered sessions/new.html.erb within layouts/application (9.5ms)
Researcher Load (0.1ms) SELECT "researchers".* FROM "researchers" WHERE "researchers"."id" IS NULL LIMIT 1
Completed 200 OK in 248ms (Views: 247.6ms | ActiveRecord: 0.1ms)
Started POST "/session" for 127.0.0.1 at 2017-05-01 18:09:23 +0100
Processing by SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "username"=>"nick1", "password"=>"[FILTERED]", "commit"=>"Enter"}
Researcher Load (0.1ms) SELECT "researchers".* FROM "researchers" WHERE "researchers"."username" = ? LIMIT 1 [["username", "nick1"]]
Redirected to http://www.example.com/
Completed 302 Found in 78ms (ActiveRecord: 0.1ms)
Started GET "/" for 127.0.0.1 at 2017-05-01 18:09:23 +0100
Processing by HomeController#index as HTML
Researcher Load (0.1ms) SELECT "researchers".* FROM "researchers" WHERE "researchers"."id" = ? LIMIT 1 [["id", 2]]
Rendered home/index.html.erb within layouts/application (0.6ms)
Completed 200 OK in 10ms (Views: 8.6ms | ActiveRecord: 0.1ms)
Started GET "/participants/3" for 127.0.0.1 at 2017-05-01 18:09:23 +0100
Processing by ParticipantsController#show as HTML
Parameters: {"id"=>"3"}
Participant Load (1.9ms) SELECT "participants".* FROM "participants" WHERE "participants"."id" = ? LIMIT 1 [["id", 3]]
Researcher Load (0.1ms) SELECT "researchers".* FROM "researchers" WHERE "researchers"."id" = ? LIMIT 1 [["id", 2]]
ContactData Load (0.2ms) SELECT "contact_data".* FROM "contact_data" WHERE "contact_data"."participant_id" = ? LIMIT 1 [["participant_id", 3]]
AlcoholService Load (0.1ms) SELECT "alcohol_services".* FROM "alcohol_services" WHERE "alcohol_services"."id" = ? LIMIT 1 [["id", 16]]
Baseline Load (0.3ms) SELECT "baselines".* FROM "baselines" WHERE "baselines"."participant_id" = ? LIMIT 1 [["participant_id", 3]]
Rendered participants/_unlock_contact_data.html.erb (1.1ms)
Rendered participants/_details.html.erb (52.8ms)
Rendered participants/show.html.erb within layouts/application (58.8ms)
Completed 200 OK in 94ms (Views: 69.9ms | ActiveRecord: 3.0ms)
Started POST "/participants/unlock_contact_data?participant_id=3" for 127.0.0.1 at 2017-05-01 18:09:24 +0100
Processing by ParticipantsController#unlock_contact_data as JS
Parameters: {"utf8"=>"✓", "from"=>"show", "password"=>"[FILTERED]", "commit"=>"Submit", "participant_id"=>"3"}
Researcher Load (0.1ms) SELECT "researchers".* FROM "researchers" WHERE "researchers"."id" = ? LIMIT 1 [["id", 2]]
Participant Load (0.0ms) SELECT "participants".* FROM "participants" WHERE "participants"."id" = ? LIMIT 1 [["id", 3]]
ContactData Load (0.1ms) SELECT "contact_data".* FROM "contact_data" WHERE "contact_data"."participant_id" = ? LIMIT 1 [["participant_id", 3]]
AlcoholService Load (0.1ms) SELECT "alcohol_services".* FROM "alcohol_services" WHERE "alcohol_services"."id" = ? LIMIT 1 [["id", 16]]
Baseline Load (0.0ms) SELECT "baselines".* FROM "baselines" WHERE "baselines"."participant_id" = ? LIMIT 1 [["participant_id", 3]]
Rendered participants/_details.html.erb (4.6ms)
Rendered participants/unlock_contact_data.js.erb (6.7ms)
Completed 200 OK in 81ms (Views: 10.8ms | ActiveRecord: 0.3ms)
(0.1ms) rollback transaction
(0.1ms) begin transaction
Is there anything I might be missing?

Failed to load resource 401 unauthorized only with Safari

I'm found an interesting problem in my app.
I'm using Rails 3 with ruby 2.0. I already have a production server where my app is running and another staging server. I'm configuring a new better one but I have a problem only with Safari.
Redirected to http://ip.server/
Completed 302 Found in 201.7ms (ActiveRecord: 0.0ms)
Started GET "/" for my.ip at 2014-10-13 08:17:18 +0200
Processing by DashboardController#index as HTML
Completed 401 Unauthorized in 1.2ms
Started GET "/user/sign_in" for my.ip at 2014-10-13 08:17:18 +0200
Processing by Devise::SessionsController#new as HTML
Rendered application/_field_errors.html.erb (0.0ms)
Rendered application/_field_errors.html.erb (0.0ms)
Rendered devise/sessions/new.html.erb within layouts/devise (2.3ms)
Completed 200 OK in 5.5ms (Views: 3.8ms | ActiveRecord: 0.0ms)
When I check on the network tab, I can see this:
Fail to load resource: the server responded with a status of 401 (unauthorized)
At the beginning I thought my problem came from Devise but then I checked on Google and find that:
cross browser problem
I tried on Chrome and it works. I tried also without AdBlock or with the private navigation but it still not working with Safari.
Edit:
I did 2 requests, one coming from Chrome and the second one from Safari. The only difference is this line:
WARNING: Can't verify CSRF token authenticity
Edit 2:
I've commented the line protect_from_forgery on my ApplicationController.rb and finally this error (about CSRF) wasn't responsible for my problem.
Here my stacks when I try with Chrome and with Safari.
With Chrome:
Started POST "/user/sign_in" for my.ip at 2014-10-14 13:27:51 +0200
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"c86MNR4MCSbQWJiAjkGtgfgPMg5YirG1tqf/2vqdBWc=", "user"=>{"email"=>"test#example.com", "password"=>"[FILTERED]", "remember_me"=>"0"}}
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`email` = 'test#example.com' LIMIT 1
(0.1ms) BEGIN
WARNING: User#current is nil, are you including SentientController on your ApplicationController?
(0.3ms) UPDATE `users` SET `last_sign_in_at` = '2014-10-14 11:26:45', `current_sign_in_at` = '2014-10-14 11:27:51', `sign_in_count` = 52, `updated_at` = '2014-10-14 11:27:51' WHERE `users`.`type` IN ('User::Admin') AND `users`.`id` = 1
(26.1ms) COMMIT
Redirected to http://server.ip/
Completed 302 Found in 135.6ms (ActiveRecord: 0.0ms)
Started GET "/" for my.ip at 2014-10-14 13:27:51 +0200
Processing by DashboardController#index as HTML
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
server.ip Rendered dashboard/index.html.erb within layouts/application (2.5ms)
Rendered application/_header.html.slim (57.6ms)
Rendered application/_sidebar.html.erb (48.1ms)
Rendered application/_page_header.html.slim (2.0ms)
Rendered application/_flash_messages.html.erb (0.5ms)
Rendered application/_footer.html.erb (0.8ms)
Completed 200 OK in 137.5ms (Views: 122.9ms | ActiveRecord: 5.1ms)
With Safari:
Started POST "/user/sign_in" for my.ip at 2014-10-14 13:27:58 +0200
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"TWKhSxus5q46H9sZdEvMnzD52r0zA5phw/Pv7K+NKuY=", "user"=>{"email"=>"test#example.com", "password"=>"[FILTERED]", "remember_me"=>"0"}}
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`email` = 'test#example.com' LIMIT 1
(0.1ms) BEGIN
(0.3ms) UPDATE `users` SET `last_sign_in_at` = '2014-10-14 11:27:51', `current_sign_in_at` = '2014-10-14 11:27:58', `sign_in_count` = 53, `updated_at` = '2014-10-14 11:27:58' WHERE `users`.`type` IN ('User::Admin') AND `users`.`id` = 1
(24.8ms) COMMIT
Redirected to http://server.ip/
Completed 302 Found in 138.2ms (ActiveRecord: 0.0ms)
Started GET "/" for my.ip at 2014-10-14 13:27:58 +0200
Processing by DashboardController#index as HTML
Completed 401 Unauthorized in 1.2ms
Started GET "/user/sign_in" for my.ip at 2014-10-14 13:27:58 +0200
Processing by Devise::SessionsController#new as HTML
Rendered application/_field_errors.html.erb (0.0ms)
Rendered application/_field_errors.html.erb (0.0ms)
Rendered devise/sessions/new.html.erb within layouts/devise (2.2ms)
Completed 200 OK in 5.2ms (Views: 3.7ms | ActiveRecord: 0.0ms)
Problem solved. It was not at all coming from my app but from my DNS redirection. I put an simple web redirection for tests and I forgot to add DNS redirection.
Now everything is working perfectly.
I hope this will help someone else!

Show attribute of form object via logger in rails

I want to debug my application and check what values are submitted on the form object in my controller class via logger ? How can it be done? Is there any better practice to debug rails application?
Your rails log (eg log/development.log) should already show everything that the form submitted, in the "Parameters". It will look like this:
Processing MusicServiceAdmin::UsersController#edit (for 127.0.0.1 at 2014-07-31 10:34:16) [GET]
Session ID: 3c0cfbe7ff23f8f718f6626748a4a
Parameters: {"id"=>"35363"}
Params
Each request in Rails is tracked using the console - you should examine the params which come through from there:
Started POST "/admin/login" for 127.0.0.1 at 2014-04-26 16:25:34 +0100
Processing by Admin::Users::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"+I1TKfc1YDuil7EI1frrFIoerNg5uonB1CIiujJO0jo=", "user"=>{"email"=>"*********", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign In"}
[1m[36mUser Load (482.0ms)[0m [1mSELECT `users`.* FROM `users` WHERE `users`.`email` = 'rpeck#frontlineutilities.co.uk' ORDER BY `users`.`id` ASC LIMIT 1[0m
[1m[35m (435.0ms)[0m BEGIN
[1m[36mSQL (439.0ms)[0m [1mUPDATE `users` SET `current_sign_in_at` = '2014-04-26 15:25:35', `last_sign_in_at` = '2014-04-04 12:08:45', `sign_in_count` = 51, `updated_at` = '2014-04-26 15:25:36' WHERE `users`.`id` = 2[0m
[1m[35m (448.0ms)[0m COMMIT
[1m[36mOption Load (404.0ms)[0m [1mSELECT `options`.* FROM `options` WHERE `options`.`name` = 'site_robots' LIMIT 1[0m
[1m[35mOption Load (357.0ms)[0m SELECT `options`.* FROM `options` WHERE `options`.`name` = 'site_title' LIMIT 1
[1m[36mOption Load (428.0ms)[0m [1mSELECT `options`.* FROM `options` WHERE `options`.`name` = 'site_description' LIMIT 1[0m
Redirected to http://lvh.me:3000/****
Completed 302 Found in 3165ms (ActiveRecord: 2993.2ms)
If you want to "debug", you just have to examine the various params / actions which are rendered in the console. Alternatively, you may also wish to the use the Rails.logger.info method for specific data:
#app/controllers/your_controller.rb
Class YourController < ApplicationController
def index
Rails.logger.info("Test")
end
end

Resources