Tony K.
2006-Dec-11 06:23 UTC
auth_generator 2.0.1 undefined method `login_required'' for ... ArticlesController
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 http://www.w3.org/2001/tag/doc/whenToUseGet.html)
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
def destroy
login_required ''editors''
Article.find(params[:id]).destroy
redirect_to :action => ''list''
end
end
------------------------------------------------------------------------
app/models/article.rb reads...
------------------------------------------------------------------------
class Article < ActiveRecord::Base
belongs_to :user
end
------------------------------------------------------------------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
