Muck Users

Installation

The muck users engine is part of the muck framework and relies upon the muck_engine as well as authlogic. Both gems should be installed automatically when you install the muck_users engine.

sudo gem install muck-users

Use search logic for searching users. Add this to environment.rb:

config.gem "binarylogic-searchlogic",
    :lib     => 'searchlogic',
    :source  => 'http://gems.github.com',
    :version => '~> 2.0.0'

In addition, you will need to install the ssl_requirement plugin (github.com/rails/ssl_requirement/tree/master) into your Rails project:

ruby script/plugin install ssl_requirement

If you used the muck template to create your rails application you will have a global_config.yml file. If not then you will need to create a global_config.yml file and then add the following to environment.rb right above Rails::Initializer.run do |config|

require 'ostruct'
require 'yaml'
::GlobalConfig = OpenStruct.new(YAML.load_file("#{RAILS_ROOT}/config/global_config.yml")[RAILS_ENV])

Inside of global_config.yml add the following changing the emails to match your application:

default: &DEFAULT

  # Sent in emails to users
  application_name: 'Name of my application'
  from_email: '[email protected]'
  support_email: '[email protected]'
  admin_email: '[email protected]'

Usage

There are a couple of routes that muck-users will look for:

Route to the site home page:

map.root '', :controller => 'default', :action => 'index'

Route to a public user page (this could also go to home etc. if needed)

map.public_user '/profiles/:id', :controller => 'profiles', :action => 'show'

This is the path that a user will be redirected to if they attempt to access another user’s dashboard page.

By default when a user logs out they are sent to the login page. You can add a new route and change the behavior:

map.logout_complete '/login', :controller => 'user_session', :action => 'new'

muck-users sends out emails that need to be able to generate links. Be sure to set a value for application_url in global_config.yml

General information

This engine implements authlogic. Some of the code contained was taken from here: railsforum.com/viewtopic.php?id=14216 and here github.com/activefx/restful_authentication_tutorial/tree/master

Inspiration also came from: github.com/tsechingho/authlogic_bundle/tree/master

Example

After installing the engine just create a user model thus:

class User < ActiveRecord::Base
  acts_as_authentic
  acts_as_muck_user
end

Then you will be able to go to: http//:localhost:3000/login http//:localhost:3000/signup

Copyright © 2009 Justin Ball, released under the MIT license