I am a relative RubNub and attempting to implement auth_generator
v.2.0.1.
I am getting an “undefined method `login_required’ for
#ArticlesController:0xb732c0b4” error when I attempt…
http://localhost:3000/articles/new
Help would be appreciated.
My app/controllers/application.rb reads…
require ‘auth_system’
class ApplicationController < ActionController::Base
include AuthSystem
helper :auth
before_filter :app_config, :ident
service :notification
Used to be able to leave out the action
def process(request, response)
catch(:abort) do
super(request, response)
end
response
end
def this_auth
@app
end
helper_method :this_auth
end
Modified the end of my config/routes.rb file to include…
map.auth 'auth/:action/:id',
:controller => 'auth', :action => nil, :id => nil
map.authadmin 'authadmin/:action/:id',
:controller => 'authadmin', :action => nil, :id => nil
As in the video example,
http://penso.info/tmp/auth_generator-demo.mov
I have modified my app/controllers/ariticles_controller.rb to read…
class ArticlesController < ApplicationController
def index
list
render :action => ‘list’
end
GETs should be safe (see
URIs, Addressability, and the use of HTTP GET and POST)
verify :method => :post, :only => [ :destroy, :create, :update ],
:redirect_to => { :action => :list }
def list
@article_pages, @articles = paginate :articles, :per_page => 10
end
def show
@article = Article.find(params[:id])
end
def new
login_required ‘editors’
@article = Article.new
end
def create
login_required ‘editors’
@article = Article.new(params[:article])
# This article belongs to the user
@user.reload
@article.user = @user
if @article.save
flash[:notice] = ‘Article was successfully created.’
redirect_to :action => ‘list’
else
render :action => ‘new’
end
end
def edit
login_required ‘editors’
@article = Article.find(params[:id])
end
def update
login_required ‘editors’
@article = Article.find(params[:id])
if @article.update_attributes(params[:article])
flash[:notice] = ‘Article was successfully updated.’
redirect_to :action => ‘show’, :id => @article
else
render :action => ‘edit’
end
end