Thanks Henry. I thought I had explained what I was trying to do in the Subject Line.
There are actually several "tabs" (in my vision of a finalized app) that I would like to prevent from appearing at all, except for users that have the "administrator checkbox" set to true. I want to have a minimum of repetetive activity both on the server and in the user's browser. What is the best way to prevent the generation of those tabs from occurring at all unless the current user is also an administrator? And how can I conditionally specify this sort of thing so that the other tabs DO appear for all users...rather than limiting the display to the Home page? Arthur ________________________________ From: Henry Baragar <[email protected]> To: [email protected] Sent: Mon, July 26, 2010 2:04:59 PM Subject: Re: [Hobo Users] Trying to display Users' Tab for Admins Only On July 26, 2010 04:47:06 pm Arthur Baldwin wrote: > Can someone please explain to me why this code produces an error that seems > to indicate that the variable "acting_user" does not yet exist, when in > fact it is referenced several times later on in the same file? > Hobo sets acting_user only when checking permissions (including in the life cycle). Google acting_user in this group to get a more complete explanation. > class User < ActiveRecord::Base > > hobo_user_model # Don't put anything above this > if acting_user.administrator? then > fields do > name :string, :required, :unique > email_address :email_address, :login => true > administrator :boolean, :default => false > timestamps > end > end > I don't think this does what you think it does. Since Hobo applications are Rails applications, and Rails reads the database schema to get the field names, these field names will be available in the application regardless of whether the "fields" section is there or not. Furthermore, when a hobo_migration is run, there is no acting_user, which means that if there had not been an error message, hobo_migration would have tried to remove these fields from the database. It would be helpful if you explained what you are trying to do. Cheers, Henry > belongs_to :group > > # --- Signup lifecycle --- # > > lifecycle do > > state :active, :default => true > > create :signup, :available_to => "Guest", > > :params => [:name, :email_address, :password, > : > :password_confirmation], > : > :become => :active > > transition :request_password_reset, { :active => :active }, :new_key => > true do > UserMailer.deliver_forgot_password(self, lifecycle.key) > end > > transition :reset_password, { :active => :active }, :available_to => > > :key_holder, > : > :params => [ :password, :password_confirmation ] > > end > > # --- Permissions --- # > > def create_permitted? > acting_user.administrator? > end > > def update_permitted? > acting_user.administrator? || > (acting_user == self && only_changed?(:email_address, > :crypted_password, > > :current_password, :password, > : > :password_confirmation)) > > # Note: crypted_password has attr_protected so although it is permitted > to change, it cannot be changed > # directly from a form submission. > end > > def destroy_permitted? > acting_user.administrator? > end > > def view_permitted?(field) > acting_user.administrator? > end > > end -- Henry Baragar Instantiated Software -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/hobousers?hl=en. -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.
