mongomapper rails 3 and devise - ruby-on-rails-3

I am using mongomapper throughotu my rails 3 app but am using authlogic and active record for authentication and storing users.
I am now changing this to devise and mongomapper like the rest of my app.
I know devise seems to now support mongoid but i don't want to mix mongid and mongomapper and now that mongomapper uses active modle it should work with devise.
I have seen some forks but they don't seem active since earlier this year.
What is the recommended way to use devise with MM now ? Isnt there just a orp adapter i now ? or do i use a fork of devise ?
cheers
Rick

Take a look at Kristian Mandrup's MM-Devise adapter: https://github.com/kristianmandrup/mm-devise
Hopefully it still works with more recent versions of Devise/MM.

I just used the mm-Devise adapter described above and it works great... You have to do some tweaking to get it to work as the documentation seemed a little out of date when used with ruby 1.9.3 and Rails 3.2.

Related

Client-side authentication with emberjs and device in Rails4

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.

How can I contribute to an existing rails gem/engine

What is the best way to extent and contribute to a rails gem/engine
I have found this blog gem/engine , which I want to use it in my rails3 application.
But there are few modifications / features I would like to have and I'm willing do code them. And after that I would like to add them to the original gem/engine (if the author permits)
But I'm confused with how and where to code and test my new changes.
So far I have done the followings
1 - Fork the gem/engine to my github account
2 - clone the source to my local machine
3 - created a sample rails app and added the gem (from my github account)
My question is,
How can I do the code changes to the gem and test them. Gem itself has used rspec and I could do that too, but some of the changes I'm planning (like layout changes), is litttle hard to check with rspec.
this gem in using rails > 3
There is an excellent ScreenCast about it: RailsCasts: Contributing to Open Source

Devise and OmniAuth-Identity

Does anyone have experience backing Devise with OmniAuth-Identity? I can't find any examples of it, and I'm not sure what params I need to set up where in order to make it happy.
I understand that OmniAuth-Identity is a completely diferent way of email-password auth, so you don't need to use devise.
This railcast episode show how to configure OmniAuth-Identity
http://railscasts.com/episodes/304-omniauth-identity

How to create user specific content, that is invisible to others?

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

Cannot get devise_oauth2_canvas_facebook to work

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.