Friday, January 4, 2008

Merbful Authentication is Born

Hooray... The initial release of merbful_authentication is cooked. It took a bit longer than I thought it would, mainly thanx to my unfamiliarity with test_unit. Well, that and I was away over the christmas holidays.

At the moment there is support for Datamapper and Activerecord ORM's. Hopefully Sequel will follow soon.

How to get it

The gem has been released on rubiforge, so the usual should do the trick
sudo gem install merbful_authentication
If you want source with that.

Git:
git clone git://activereload.net/restful_authentication.git merbful_authentication.git
git checkout -b local/merbful_authetication origin/merbful_authentication
Or SVN
svn co svn://rubyforge.org/var/svn/merbful-auth
From either of these you can package and install the gem
rake package
sudo gem install pkg/merbful_authentication-0.1.0.gem

Usage

It has the same usage as restful_authentication, without the stateful stuff. So (from README)
To use:

./script/generate authenticated user sessions \
--include-activation

The first parameter specifies the model that gets created in signup
(typically a user or account model). A model with migration is
created (if migrations are available), as well as a basic controller with the create method.

The second parameter specifies the sessions controller name. This is
the controller that handles the actual login/logout function on the
site.

The third parameter (--include-activation) generates the code for a
Mailer and the required support code. Don't forget to setup your mailer for this.

Required Setup

Unfortunately there is some setup required. At the moment, some named routes are required. You can set these up in you config/router.rb
      r.resources :users
r.match("/login").to(:controller => "Sessions", :action => "create").name(:login)
r.match("/logout").to(:controller => "Sessions", :action => "destroy").name(:logout)
r.match("/users/activate/:activation_code").to(:controller => "Users", :action => "activate").name(:user_activation)
That last one is only required if you include activation. Don't forget to setup your mailer configs if your using it too.

Also, you need to have merb_helpers installed. This is for the form generation stuff. In config/dependencies.rb
dependency "merb_helpers"
All crit, comments, bug reports, patches are welcome. Patches are more welcome of course ;)

Update: You will need to install merb and merb_helpers from trunk until the official 0.5 gem for merb comes out.

16 comments:

zapnap said...

Nice, this makes the Merb argument even more compelling. And with support for DataMapper, too! Very cool, and many thanks. Looking forward to using it in my next project.

fred said...

This is awesome! thanks for the work.

I just checked out Merb a month ago, and now we have this great plugin...

Yet another reason to start using merb.

deimos1986 said...

Sweet, will have to give it a spin later.

naruto said...

Hey Hassox, you ever see this error when you do a rake gem? Wondering if you encountered this...

merb_helpers # rake gem
(in /gems/merb_helpers)
/usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.1/lib/spec/runner/options.rb:216:in `files_to_load': File or directory not found: gem (RuntimeError)
from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.1/lib/spec/runner/options.rb:210:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.1/lib/spec/runner/options.rb:210:in `files_to_load'
from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.1/lib/spec/runner/options.rb:83:in `run_examples'
from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.1/lib/spec.rb:20:in `run'
from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.1/lib/spec.rb:34
from /usr/local/bin/rake:19

Daniel Neighman said...

@naruto this is an issue I've seen when using datamapper with the latest Rspec. If you downgrade your rspec it should work while a work around is found.

Although, for merb_helpers you should just use rake install not rake gem

naruto said...

Thanks for the info! I'm going to downgrade right now.

naruto said...

@hassox:

Thanks for the tip earlier. That worked, but I get an error when I run the generate script. Any ideas?

./script/generate authenticated user sessions --include-activation

Couldn't find 'authenticated' generator

Daniel Neighman said...

@naruto

It couldn't find it because I buggered it up. I've called the generator "authentication" by mistake. I'll fix this and update it to "authenticated". For now just use "authentication" and you should be ok

naruto said...

@hassox

Thanks! Got another one now...

./script/generate authentication user sessions --include-activation
exists app/controllers/
exists app/controllers/
exists app/helpers/
create app/views/sessions
exists app/controllers/
exists app/helpers/
create app/views/users
exists lib
create lib/authenticated_system_controller.rb
create lib/authenticated_system_model.rb
create app/mailers/views/user_mailer
create app/mailers/user_mailer.rb
create app/mailers/views/user_mailer/signup_notification.html.erb
create app/mailers/views/user_mailer/activation_notification.html.erb
create app/mailers/views/user_mailer/signup_notification.text.erb
create app/mailers/views/user_mailer/activation_notification.text.erb
dependency merbful_authentication_model
Couldn't find 'merbful_authentication_model' generator


Am I forgetting something?

Daniel Neighman said...

@naruto

You need to have selected an ORM (either AR or DM) to use before you generate.

You do this in dependencies.rb with
use_orm :datamapper
or
use_orm :activerecord

naruto said...

oh oops...i forgot that when i created a new merb app, everything is blanked out...

my bad...sorry...

Brad said...

This is awesome. Heh, I seem to Remember A sImiLar framework growing rapidly with a Similar plugin.

Hopefully this is the start of many great plugins to come to merb - great work.

dotmariusz said...

./script/generate authenticated user sessions --include-activation


Merb 0.9 doesn't use ./script/generate anymore ;)

Alex Coles said...

Also check out this unofficial patch (not written by me, but its working for me) to get merb_authentication working with Merb 0.9.

http://pastie.textmate.org/private/5slvszmguuqhrphwmzemrg

No problems so far.

Anonymous said...

I would like to use this plugin without an ORM ;)

carpet cleaners said...

black mold exposureblack mold symptoms of exposurewrought iron garden gatesiron garden gates find them herefine thin hair hairstylessearch hair styles for fine thin hairnight vision binocularsbuy night vision binocularslipitor reactionslipitor allergic reactionsluxury beach resort in the philippines

afordable beach resorts in the philippineshomeopathy for eczema.baby eczema.save big with great mineral makeup bargainsmineral makeup wholesalersprodam iphone Apple prodam iphone prahacect iphone manualmanual for P 168 iphonefero 52 binocularsnight vision Fero 52 binocularsThe best night vision binoculars here

night vision binoculars bargainsfree photo albums computer programsfree software to make photo albumsfree tax formsprintable tax forms for free craftmatic air bedcraftmatic air bed adjustable info hereboyd air bedboyd night air bed lowest pricefind air beds in wisconsinbest air beds in wisconsincloud air beds

best cloud inflatable air bedssealy air beds portableportables air bedsrv luggage racksaluminum made rv luggage racksair bed raisedbest form raised air bedsbed air informercialsbest informercials bed airmattress sized air beds

bestair bed mattress antique doorknobsantique doorknob identification tipsdvd player troubleshootingtroubleshooting with the dvd playerflat panel television lcd vs plasmaflat panel lcd television versus plasma pic the bestadjustable bed air foam The best bed air foam

hoof prints antique equestrian printsantique hoof prints equestrian printsBuy air bedadjustablebuy the best adjustable air bedsair beds canadian storesCanadian stores for air beds

migraine causemigraine treatments floridaflorida headache clinicdrying dessicantair drying dessicantdessicant air dryerpediatric asthmaasthma specialistasthma children specialistcarpet cleaning dallas txcarpet cleaners dallascarpet cleaning dallas

vero beach vacationvero beach vacationsbeach vacation homes veroms beach vacationsms beach vacationms beach condosmaui beach vacationmaui beach vacationsmaui beach clubbeach vacationsyour beach vacationscheap beach vacations

bob hairstylebob haircutsbob layeredpob hairstylebobbedclassic bobCare for Curly HairTips for Curly Haircurly hair12r 22.5 best pricetires truck bustires 12r 22.5

washington new housenew house houstonnew house san antonionew house venturanew houston house houston house txstains removal dyestains removal clothesstains removalteeth whiteningteeth whiteningbright teeth

jennifer grey nosejennifer nose jobscalebrities nose jobsWomen with Big NosesWomen hairstylesBig Nose Women, hairstyles