Simple question

i recive the error "undefined method `admin?’ for

from this line :


47: <%= link_to ‘Edit’[:edit_title], edit_forum_path(forum),
:class => “tiny”, :rel => “directory”, :style => “float:right” if admin?

the forums controller contains the function :

def logged_in?


what am i doing wrong ? where does rails look for admin?

You haven’t definied a method admin? anywhere that I can see in the code
you’ve provided so why are you trying to call it?

On Tue, Mar 18, 2008 at 10:08 PM, Gady S. <
[email protected]> wrote:

47: <%= link_to ‘Edit’[:edit_title], edit_forum_path(forum),
what am i doing wrong ? where does rails look for admin?

Posted via

Ryan B.
Feel free to add me to MSN and/or GTalk as this email.

pasted the wrong method. i have the method

def admin?
in the forums controller

Ryan B. wrote:

You haven’t definied a method admin? anywhere that I can see in the code
you’ve provided so why are you trying to call it?

Hey instead of calling as if admin? do it like this…
if @controller.admin
@controller is the instance variable of current controller which is
forum in your case

As described, Rails is looking for the view to have a method called
‘admin?’ somewhere (possibly in a helper method) but it does not. If
you have an object that you want to share between the controller and
the view that has the ‘admin?’ method on it then you normally do that
by defining an instance variable on the controller which is then
copied over to the view for you by Rails.

It appears that you’re using acts_as_authenticated or
restful_authentication. If that’s the case then you probably want to
use a method on @current_user.

On Mar 18, 7:50 am, Gady S. [email protected]

well i’m trying to integrate savage beast 2 (without using the engine)
with restful authentication.
that line of code was originaly from savage beast 2
so the method admin? should be in one of the helpers ?
does applicatiob.rb has anything todo with it ?
i’m asking because one of the steps for installing savage beast 2 (with
the engine) is to “Implement versions of the methods in
but i’m not sure how to implement those without the plugin.

here is the associated file :

module SavageBeast::AuthenticationSystem

#this is a shell that Savage Beast uses to query the current user - 

overide in your app controller

# update_last_seen_at
# this is used to keep track of the last time a user has been seen 

(reading a topic)
# it is used to know when topics are new or old and which should
have the green
# activity light next to them
# we cheat by not calling it all the time, but rather only when a
user views a topic
# which means it isn’t truly “last seen at” but it does serve it’s
intended purpose
# this could be a filter for the entire app and keep with it’s true
meaning, but that
# would just slow things down without any forseeable benefit since
we already know
# who is online from the user/session connection
# This is now also used to show which users are online… not at
accurate as the
# session based approach, but less code and less overhead.
#def update_last_seen_at
# return unless logged_in?
# User.update_all [‘last_seen_at = ?’,], [‘id = ?’,]
# current_user.last_seen_at =
def update_last_seen_at

#def login_required
#  login_by_token      unless logged_in?
#  login_by_basic_auth unless logged_in?
#  respond_to do |format|
#    format.html { redirect_to login_path }
#    format.js   { render(:update) { |p| p.redirect_to login_path } 

# format.xml do
# headers[“WWW-Authenticate”] = %(Basic realm=“Beast”)
# render :text => “HTTP Basic: Access denied.\n”, :status =>
# end
# end unless logged_in? && authorized?
def login_required

#def login_by_token
#  self.current_user = 

User.find_by_id_and_login_key(*cookies[:login_token].split(";")) if
cookies[:login_token] and not logged_in?
def login_by_token

#def authorized?() true end
def authorized?() true end

def current_user=(value)

if @current_user = value

session[:user_id] =

# this is used while we’re logged in to know which threads are

new, etc

session[:last_active] = @current_user.last_seen_at

session[:topics] = session[:forums] = {}




def current_user=(value)


#def current_user
#  @current_user ||= ((session[:user_id] && 

User.find_by_id(session[:user_id])) || 0)
def current_user

#def logged_in?
#  current_user != 0
def logged_in?

#def admin?
#  logged_in? && current_user.admin?
def admin?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs