I'm getting a "TypeError in Devise::FacebookConsumersController#callback: can't convert Hash into Integer" when I try to authenticate using Devise and devise_oauth2_canvas_facebook gem with the new Facebook API. Any ideas what can be the problem?
It look like mooktakim the creator of the devise_oauth2_canvas_facebook gem is not updating it anymore.
Here is his message on a pull request to that effect:
https://github.com/mooktakim/devise_oauth2_facebook/pull/9
He says that he is moving to Omnisocial
https://github.com/icelab/omnisocial#readme
This uses Omniauth which allows you to use logins from many different sources.
It might be better for you to move to Omniauth.
Related
I'm pretty new to Rails, but followed the excellent suggestion/walkthrough here. I've gotten the creation of my two user types (Clients and Developers) to work successfully with Devise. However, I also want to allow both user types to edit some of their attributes after they are logged in. These attributes are also specific to their user types (client specific fields or developer specific fields).
To do this, I thought that I needed to create a custom update in user_registrations_controller which inherits from Devise::RegistrationController as would make sense. During my customization however, I realize within update I am unable to call other default methods from Devise::RegistrationController. As a sanity check, I overrode update with an exact copy of the update method as defined in the original Devise::RegistrationController and still had this issue.
More specifically, the error I receive is: undefined local variable or method 'account_update_params' for #<UserRegistrationsController:0x007fe4f0342d58>, despite account_update_params being a method in the inherited controller.
Is there a better way to edit the fields specific to my user types (client/developer) in Devise without having to customize update? Also, what is going on with this error here, as I believe I am inheriting from Devise::RegistrationController?
Any thoughts? Help and suggestions much appreciated! =)
Versions: Rails 3.2.12, ruby 1.9.3p249
After revisiting this, I found this related question. Though this post and top answer is specific to Rails 4, the solution can be found in the Gemfile.
Replace your devise gem include with
gem 'devise', :git => 'git://github.com/plataformatec/devise.git'
Simply doing gem 'devise' does not get this updated version, unfortunately. Hope this helps others!
Working with user resources is an essential part of every application an so there it's a task which should be automated as much as possible.
As for Ember I found a tutorial https://github.com/heartsentwined/ember-auth-rails-demo/wiki
which describes how it can communicate with devise-based authentication system. And, wow, it's a hell of a boilerplate:)
Have something changed with new devise for Rails4 or things are the same?
ember-auth dev here.
Edit / Update for googlers: I have now built a rails 4 app, with devise, ember, and ember-auth. Apart from the following two gotchas, everything is working fine.
devise >= 3.1 removed the tokenAuthenticatable module. So I'd declare in my Gemfile:
gem 'devise', '>= 3.0', '< 3.1'
ember-data is drifting away from ActiveModelSerializers, towards json-api. Problem is, json-api itself isn't even stable. The quick and easy fix is to replace DS.RESTAdapter with DS.ActiveModelAdapter, which follows the ActiveModelSerializers conventions. It should "just work".
So, yeah, ember-auth does support rails4, because there is nothing BC-breaking with it per se.
(Previous answer:)
I have no experience with rails 4, but ember-auth itself doesn't rely on rails 3, or in fact rails / devise in particular. The only expectation is a set of API that your server exposes.[1] The docs describe the expectation from the server API.
As for using rails as a backend, ember-data explicitly declares support (and adherence to) active_model_seriailzers, which provides convenience methods for churning out json responses from rails models. However, since authentication actions do not conform to the "standard" RESTful model responses, the ember-auth-rails-demo tutorial itself hand-crafts the expected responses. Example:
def create
# ...
data = {
user_id: resource.id,
auth_token: resource.authentication_token,
}
if params[:remember]
resource.remember_me!
data[:remember_token] = remember_token(resource)
end
render json: data, status: 201
end
So, for rails 4 compatibility, I would investigate more on devise compatibility, any ActiveRecord changes, and in general other gem compatibilities as needed. As for ember-auth, it will still be handcrafting the expected responses, as outlined in the docs.
[1]: Even this expectation would be customizable, by writing customized adapters. Advanced usage, but I can elaborate more on this if needed.
I want to use premailer-rails to generate text part of email automatically.
gem 'hpricot'
gem "premailer-rails"
I'm not getting the text part when I look at the actual email.
It seems as if the gem is not enabled. Any idea why?
If the gem is not working, it may be because you are missing an initializer
Add this code in config/initializers/premailer_rails.rb
Premailer::Rails.config.merge!(preserve_styles: true, remove_ids: true)
Also
If you're using this gem outside of Rails, you'll need to call Premailer::Rails.register_interceptors manually in order for it to work. This is done ideally in some kind of initializer, depending on the framework you're using.
You can find this information on the gem's Github page https://github.com/fphilipe/premailer-rails.
On another note, they also recomend to use nokogiri instead of hpricot, seeing as the latter is no longer mantained.
I am absolutely new to Ruby on Rails, even to programming at all. I got started with Michael Hartl's Rails Tutorial using Rails 3.0.10. Now I alter its aim towards creating an application that allows users to manage their own "projects". These projects are to be exclusively available to the logged-in user, thus, invisible to others.
My problem is: I am unable to create a page with an URL like "~/users/1/projects", I don't know about the routing. All i get done is "~/projects", which is fairly not what i want at all. So, how do I get this problem fixed? Or am I totally off track with that idea?
I generated a Projects model by scaffolding. So, how can I implement it for the signed-in users?
this would be done by creating a nested resource. when you are new to rails and programming you should work yourself a way through a lot of tutorials and guides.
a good place to get an overview are the official rails guides. in this specific case the chapter about routing: http://guides.rubyonrails.org/routing.html#nested-resources
# config/routes.rb
resources :users do
resources :projects
end
Im trying to use the gem Devise for a admin authentication. Ive used it before when I only wanted a user login but now I would like to have just a admin login. I followed the railscast for it and instead of naming the model User I gave it the name Admin. Everything worked fine until I tried to login then I got this error message:
uninitialized constant Devise::Encryptors::Bcrypt
I cant seem to find the problem. I have compared the code in the project with the other one I did and there is no difference. Is the problem due to the fact that I´m using Admin the wrong way?! Should I not use it as you would with a user?! Thankful for all help.
Regards
That encryption method appears to have been removed from Devise.
See: https://github.com/plataformatec/devise/issues/issue/527