I am using Clearance gem. It's "half" working.
I can do all basic actions (sign up, sign in, :authorize).
But, when I do a POST action to a controller, it just signs me out ...
Here what's in the log :
Started POST "/monkeys" for 127.0.0.1 at Fri Jun 03 06:22:00 -0400 2011
Processing by MonkeysController#create as HTML
Parameters: {"commit"=>"Save monkey", "authenticity_token"=>"[FILTERED]", "utf8"=>"\342\234\223", "monkey"=>{"name"=>"fghfgh", "description"=>"fghfgh"}}
User Load (0.1ms) SELECT `users`.* FROM `users` WHERE `users`.`remember_token` = 'c1f450a81fde65282e73ce41f69095b66d782e34' LIMIT 1
SQL (0.1ms) BEGIN
AREL (0.3ms) UPDATE `users` SET `remember_token` = 'b9c2cac3d446bee370e40619c6c8cd42c457bb13', `updated_at` = '2011-06-03 10:22:00' WHERE `users`.`id` = 4
SQL (1.1ms) COMMIT
Redirected to http://localhost:3000/sign_in
When that happens, I am actually signed in.. what might I have missed?
Thanks
It was actually because of my cookie domain, for some reason, localhost is not right. So i added a simple dns called "monkey.local" on my machine, and now I access the application with it and all works fine.
I also believe I can use 127.0.0.0 and it would work. I'll try it at home.
Related
I've got a RefineryCMS 3 application and in the backend the thumbnails for uploaded images are not showing up.
If I run the app in production mode on my development machine then the thumbnails show up. On the production machine the rails app is ran through passenger & apache and it fails.
I have copied my development copy to the production server for a test and ran the refinery project in development mode and I still get the same issue
rails s -b 192.168.200.215
Here is the standard output when I try and load the images area in refinery admin;
Started GET "/refinery/images" for 192.168.200.4 at 2016-03-01 15:32:25 +1100
Processing by Refinery::Admin::ImagesController#index as HTML
Parameters: {"locale"=>:en}
Refinery::Authentication::Devise::User Load (0.2ms) SELECT "refinery_authentication_devise_users".* FROM "refinery_authentication_devise_users" WHERE "refinery_authentication_devise_users"."id" = ? ORDER BY "refinery_authentication_devise_users"."id" ASC LIMIT 1 [["id", 1]]
Refinery::Authentication::Devise::Role Load (0.1ms) SELECT "refinery_authentication_devise_roles".* FROM "refinery_authentication_devise_roles" INNER JOIN "refinery_authentication_devise_roles_users" ON "refinery_authentication_devise_roles"."id" = "refinery_authentication_devise_roles_users"."role_id" WHERE "refinery_authentication_devise_roles_users"."user_id" = ? [["user_id", 1]]
Rendered /var/lib/gems/2.1.0/gems/refinerycms-acts-as-indexed-2.0.1/app/views/refinery/acts_as_indexed/admin/_search_header.html.erb (0.2ms)
Rendered /var/lib/gems/2.1.0/gems/refinerycms-core-3.0.1/app/views/refinery/admin/_search_header.html.erb (4.4ms)
(0.2ms) SELECT COUNT(*) FROM "refinery_images"
CACHE (0.0ms) SELECT COUNT(*) FROM "refinery_images"
Refinery::Image Load (0.3ms) SELECT "refinery_images".* FROM "refinery_images" ORDER BY updated_at DESC LIMIT 20 OFFSET 0
Refinery::Image::Translation Load (0.3ms) SELECT "refinery_image_translations".* FROM "refinery_image_translations" WHERE "refinery_image_translations"."refinery_image_id" IN (2)
Rendered /var/lib/gems/2.1.0/gems/refinerycms-images-3.0.1/app/views/refinery/admin/images/_grid_view.html.erb (10.3ms)
Rendered /var/lib/gems/2.1.0/gems/refinerycms-images-3.0.1/app/views/refinery/admin/images/_images.html.erb (14.5ms)
Rendered /var/lib/gems/2.1.0/gems/refinerycms-images-3.0.1/app/views/refinery/admin/images/_records.html.erb (33.7ms)
Rendered /var/lib/gems/2.1.0/gems/refinerycms-acts-as-indexed-2.0.1/app/views/refinery/acts_as_indexed/admin/_search.html.erb (2.2ms)
Rendered /var/lib/gems/2.1.0/gems/refinerycms-core-3.0.1/app/views/refinery/admin/_search.html.erb (4.8ms)
Rendered /var/lib/gems/2.1.0/gems/refinerycms-images-3.0.1/app/views/refinery/admin/images/_actions.html.erb (17.0ms)
Rendered /var/lib/gems/2.1.0/gems/refinerycms-images-3.0.1/app/views/refinery/admin/images/index.html.erb within layouts/refinery/admin (61.1ms)
Rendered /var/lib/gems/2.1.0/gems/refinerycms-core-3.0.1/app/views/refinery/_html_tag.html.erb (0.2ms)
Rendered /var/lib/gems/2.1.0/gems/refinerycms-core-3.0.1/app/views/refinery/admin/_javascripts.html.erb (159.9ms)
Rendered /var/lib/gems/2.1.0/gems/refinerycms-core-3.0.1/app/views/refinery/admin/_head.html.erb (232.9ms)
Rendered /var/lib/gems/2.1.0/gems/refinerycms-core-3.0.1/app/views/refinery/_site_bar.html.erb (3.4ms)
Rendered /var/lib/gems/2.1.0/gems/refinerycms-core-3.0.1/app/views/refinery/admin/_menu_item.html.erb (28.4ms)
Rendered /var/lib/gems/2.1.0/gems/refinerycms-core-3.0.1/app/views/refinery/admin/_menu.html.erb (31.9ms)
Rendered /var/lib/gems/2.1.0/gems/refinerycms-core-3.0.1/app/views/refinery/_no_script.html.erb (0.3ms)
Rendered /var/lib/gems/2.1.0/gems/refinerycms-core-3.0.1/app/views/refinery/_message.html.erb (0.1ms)
Completed 200 OK in 375ms (Views: 362.0ms | ActiveRecord: 1.1ms)
Started GET "/system/images/W1siZiIsIjIwMTYvMDMvMDEvN3lmN3ZpNDRtZV9hYWEuanBnIl0sWyJwIiwidGh1bWIiLCIxMzV4MTM1I2MiXV0/aaa.jpg?sha=7a0325c4ef12ef3d" for 192.168.200.4 at 2016-03-01 15:32:27 +1100
When it tries to get the /system/images/.... it fails in the web browser console. If I try and access that directly with the following
http://192.168.200.215:3000/system/images/W1siZiIsIjIwMTYvMDMvMDEvN3lmN3ZpNDRtZV9hYWEuanBnIl0sWyJwIiwidGh1bWIiLCIxMzV4MTM1I2MiXV0/aaa.jpg
I get the following error in the browser
Internal Server Error
The production server didn't have imagemagick installed.
sudo apt-get install imagemagick
This fixed it.
I set up omniauth-password exactly as shown here:
https://github.com/namick/omniauth-password
I, however, get an invalid_credentials error every time I try to sign in. Now, there are no users in my database so it should be creating them right? I'm kind of confused where registration fits into this.
The problem is that my controller is not even being called. Here are the logs.
(password) Callback phase initiated.
(password) Authentication failure! invalid_credentials encountered.
Started POST "/auth/password/callback" for 127.0.0.1 at 2012-12-05 02:34:05 -0800
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."email" = 'asd#asf.comssdf' LIMIT 1
Started GET "/auth/failure?message=invalid_credentials&strategy=password" for 127.0.0.1 at 2012-12-05 02:34:05 -0800
Processing by SessionsController#failure as HTML
Parameters: {"message"=>"invalid_credentials", "strategy"=>"password"}
Rendered text template (0.0ms)
Completed 200 OK in 16ms (Views: 15.4ms | ActiveRecord: 0.0ms)
Any help appreciated!
not quite answering your specific problem with omniauth-password but,
have you considered using omniauth-identity?
It's a database-based strategy that used username (or email) and password credentials, and there is a Railscast of it.
And: I succesfuully made it work with other strategies.
Omniauth-identity: https://github.com/intridea/omniauth-identity
Railscast: http://railscasts.com/episodes/304-omniauth-identity
I've a problem with a slow post request in a RoR app.
the project is a distribuited system wher the client send a lot of photos and the server save those in DB.
I use MySql server 5.1, both client and the server are in the same local network and they are programmer in RoR....
the client send 10 photo in a single request. the 10 photos are send in an array structure in yaml format.
the request is:
res = Net::HTTP.post_form(uri, :mac => 'String', :value => 'Yaml_array_images_data', :num => 10)
and the log says:
`Started POST "/events/save_photo" for 192.168.0.113 at 2012-03-30 09:45:10 +0200
Processing by EventsController#save_photo as */*
Parameters: {"data_type"=>"image", "value"=>"--- \n- !binary |\n /9j/2wCEAAoH
BwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYI...", "created_at"=>"--- \n- 2012-03-30 09:26:29 +02:00 \n-....", "mac"=>"00606E91E5D2"}
(0.3ms) SET PROFILING=1
Device Load (1.2ms) SELECT SQL_NO_CACHE `devices`.* FROM `devices`
WHERE `devices`.`mac` = '00606E91E51E' LIMIT 1
CACHE (0.0ms) SELECT `devices`.* FROM `devices` WHERE `devices`.
`mac` = '00606E91E51E' LIMIT 1
(0.3ms) BEGIN
SQL (2.9ms) INSERT INTO `multimedia` (`created_at`, `data`, `eve
nt_id`, `updated_at`) VALUES ('2012-03-30 07:45:00', x'f22b19237b63f1c8c40da49ae
5eb68969dd3cf28193ba6a3704fe2f286494439eea4f9071bb6ef9de530ccaaab235a402e2d94aad
2f4f1b90df022c23078f543bc6ca1c6fe8b17af45eae865bb....)
(0.3ms) SET PROFILING=1
Device Load (1.2ms) SELECT SQL_NO_CACHE `devices`.* FROM `devices`
WHERE `devices`.`mac` = '00606E91E51E' LIMIT 1
CACHE (0.0ms) SELECT `devices`.* FROM `devices` WHERE `devices`.
`mac` = '00606E91E51E' LIMIT 1
(0.3ms) BEGIN
SQL (2.9ms) INSERT INTO `multimedia` (`created_at`, `data`, `eve
nt_id`, `updated_at`) VALUES ('2012-03-30 07:45:00', x'f22b19237b63f1c8c40da49ae
5eb68969dd3cf28193ba6a3704fe2f286494439eea4f9071bb6ef9de530ccaaab235a402e2d94aad
2f4f1b90df022c23078f543bc6ca1c6fe8b17af45eae865bb...)
(44.0ms) COMMIT
(0.3ms) BEGIN
SQL (0.8ms) INSERT INTO `events` (`created_at`, `data_type`, `devic
e_id`, `element_id`, `multimedia_id`, `name`, `status`, `updated_at`, `value`) V
ALUES ('2012-03-30 07:45:00', 'image', 19, 413397, 1066303, 'photo', NULL, '2012
-03-30 07:45:11', '--- 0\n...\n')
(38.2ms) COMMIT
(0.3ms) BEGIN
SQL (2.9ms) INSERT INTO `multimedia` (`created_at`, `data`, `eve
nt_id`, `updated_at`) VALUES ('2012-03-30 07:45:01', x'f22b19237b63f1c8c40da49ae
5eb68969dd3cf28193ba6a3704fe2f28...)
....
for 10 times insert a record in multimedia and one in events table
...
(33.0ms) COMMIT
(0.3ms) BEGIN
(0.4ms) SET PROFILING=1
(1.3ms) SELECT SQL_NO_CACHE 1 FROM `devices` WHERE (`devices`.`mac
` = BINARY '00606E91E51E' AND `devices`.`id` != 19) LIMIT 1
(0.7ms) UPDATE `devices` SET `elem_photo_id` = 413408, `updated
_at` = '2012-03-30 07:45:12' WHERE `devices`.`id` = 19
(34.5ms) COMMIT
Rendered events/save_photo.html.erb (0.2ms)
Completed 200 OK in 1957ms (Views: 10.2ms | ActiveRecord: 1466.6ms)`
My first problem is the difference by total time and the sum between views time and activerecord time.
After that this times are in the log of the server, so those are the execution time of the request. If I take the time, in the client, from send request to receive respond, it's 3,6 seconds! Why? I don't think that in local network are needed 2 second to transfer 200k!
there's a lot of things happening between client sending request and server sending response
to name a few:
client resolves dns(usually it's cached)
client initiates http connection
client actually posts the data
whatever server you have there accepts post request and enqueues it to be processed by your rails stack
request goes through all the rack middlewares you have before actually hitting your controller
your request is processed by controller and response is generated
response is then transferred to client and browser parses and renders it
what you see in your server logs is probably only point 6, everything else depends on your app setup and properties of your response(html with lots of css, javascripts, images, etc)
regarding your problem with time differences in this line:
Completed 200 OK in 1957ms (Views: 10.2ms | ActiveRecord: 1466.6ms)
detailed time consumption(in parenthesis) is not entirely detailed. it is missing GC time(which probably was invoked if you send files as yaml-formatted parameters), it is also missing time spent in your before filters and action itself.
I'm building my first webapp, following the Michael Hartl Rails Tutorial. After finishing Chapter 10, I find that my application works locally but does not work when I push it to Heroku. The development log output reads:
Started GET "/" for 98.154.183.51 at Thu Jan 06 01:07:15 -0800 2011
Processing by PagesController#home as HTML
Rendered layouts/_header.html.erb (28.3ms)
Rendered pages/home.html.erb within layouts/application (30.9ms)
Completed in 35ms
User Load (29.6ms) SELECT "users".* FROM "users" WHERE ("users"."id" = 101) LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE ("users"."id" = 101) LIMIT 1
Rendered layouts/_header.html.erb (149.3ms)
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE ("users"."id" = 101) LIMIT 1
Rendered layouts/_sidebar.html.erb (8.1ms)
Rendered layouts/_footer.html.erb (0.6ms)
Rendered sessions/new.html.erb within layouts/application (342.4ms)
Completed 200 OK in 421ms (Views: 390.1ms | ActiveRecord: 29.9ms)
Whereas the heroku production log reads:
Started GET "/" for 98.154.183.51 at Thu Jan 06 01:07:15 -0800 2011
Processing by PagesController#home as HTML
Rendered layouts/_header.html.erb (28.3ms)
Rendered pages/home.html.erb within layouts/application (30.9ms)
Completed in 35ms
ActionView::Template::Error (PGError: ERROR: invalid input syntax for integer: "nil"
: SELECT "users".* FROM "users" WHERE ("users"."id" = 'nil') LIMIT 1):
I'm not sure why the Heroku-deployed app looks for a user_id of "nil", whereas my local app looks for one of "101." This is my first app, so I'm not sure where to even begin the troubleshooting. I've tried pushing my local db to the Heroku one via heroku rake db:push, but I still get the same errors. Any advice? Thanks in advance for your help.
Make sure you
Migrated your database on Heroku with heroku rake db:migrate
Have a valid user in your database (you could e.g. create one with the Rails console on Heroku)
It seems your code is trying to load a User instance when you have none in your database. If your app works once you have some users in your database, fix your code to act appropriately if no users are present.
You might want to run you rake db:seed also if you have setup some initial values.
My app was working fine with Rails 2.2 and Facebooker 1.0.13, but I keep getting a 406 error with Rails 2.3.
I checked the mime type, canvas/iframe setting in Facebook, and the requests work fine outside of Facebook (i.e. I get the full app as long as I'm not accessing it within the Facebook iframe). Has something changed recently in the Facebook API that would cause this error? Or is there anything in Facebooker that you've found might be fixed quickly?
Here is my Dev log for reference:
Processing PostsController#index (for xx.xxx.xx.xxx at 2009-03-06 03:24:44) [GET]
Parameters: {"fb_sig_app_id"=>"xxxxx",
"fb_sig_in_iframe"=>"1",
"fb_sig_locale"=>"en_US",
"fb_sig_in_new_facebook"=>"1",
"fb_sig"=>"xxxxx",
"fb_sig_added"=>"1",
"fb_sig_expires"=>"xxxxx",
"fb_sig_session_key"=>"xxxxx",
"fb_sig_ss"=>"xxxxx",
"fb_sig_api_key"=>"xxxxx",
"fb_sig_time"=>"1236327886.7997",
"fb_sig_profile_update_time"=>"1228275036",
"fb_sig_user"=>"11111"}
User Columns (6.0ms) SHOW FIELDS FROM users
User Load (1.0ms) SELECT * FROM users WHERE (users.login = 11111) LIMIT 1
SQL (0.0ms) BEGIN
SQL (0.0ms) COMMIT
Competition Load (0.0ms) SELECT * FROM posts
Completed in 135ms (View: 8, DB: 8) | 406 Not Acceptable
[http://xx.xx.xxx.xxx/?fb_sig_in_iframe=1&
fb_sig_locale=en_US&
fb_sig_in_new_facebook=1&
fb_sig_time=xxxxx.xxxxx&
fb_sig_added=1&
fb_sig_profile_update_time=1228275036&
fb_sig_expires=xxxxx&
fb_sig_user=xxxxx&
...]
If more details are needed, I'll be glad to give them...:-)
Found the answer in the Facebook Forums:
http://forum.developers.facebook.com/viewtopic.php?pid=93648#p93648
Sorry for implying that Facebooker wasn't working correctly...What you're doing is GREAT Michael (et al), keep up the great work!