Hi i recive the error "undefined method `admin?'' for #<ActionView::Base:0x484acd4> " from this line : forums/index.html.erb 46: <td class="c3"> 47: <%= link_to ''Edit''[:edit_title], edit_forum_path(forum), :class => "tiny", :rel => "directory", :style => "float:right" if admin? %> 48: </td> the forums controller contains the function : def logged_in? end what am i doing wrong ? where does rails look for admin? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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 Sujo < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi > i recive the error "undefined method `admin?'' for > #<ActionView::Base:0x484acd4> > " > > from this line : > forums/index.html.erb > > 46: <td class="c3"> > 47: <%= link_to ''Edit''[:edit_title], edit_forum_path(forum), > :class => "tiny", :rel => "directory", :style => "float:right" if admin? > %> > 48: </td> > > the forums controller contains the function : > > def logged_in? > > end > > what am i doing wrong ? where does rails look for admin? > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
oops pasted the wrong method. i have the method def admin? true end in the forums controller Ryan Bigg 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? >-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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 Sujo <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> oops > pasted the wrong method. i have the method > > def admin? > true > end > in the forums controller > > Ryan Bigg 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? > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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 On Mar 18, 5:00 pm, AndyV <a...-HmMyXyqgL2CVc3sceRu5cw@public.gmane.org> wrote:> 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 Sujo <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > oops > > pasted the wrong method. i have the method > > > def admin? > > true > > end > > in the forums controller > > > Ryan Bigg 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? > > > -- > > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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 SavageBeast::AuthenticationSystem" 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 = ?'', Time.now.utc], [''id = ?'', current_user.id] # current_user.last_seen_at = Time.now.utc #end def update_last_seen_at end #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 => :unauthorized # end # end unless logged_in? && authorized? #end def login_required end #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? #end def login_by_token end #def authorized?() true end def authorized?() true end # def current_user=(value) # if @current_user = value # session[:user_id] = @current_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] = {} # update_last_seen_at # end # end def current_user=(value) end #def current_user # @current_user ||= ((session[:user_id] && User.find_by_id(session[:user_id])) || 0) #end def current_user end #def logged_in? # current_user != 0 #end def logged_in? end #def admin? # logged_in? && current_user.admin? #end def admin? end end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---