Why is users drop down visible in hobo new action ?

24 views
Skip to first unread message

Vivek Sampara

unread,
Jun 9, 2012, 10:30:39 AM6/9/12
to hobo...@googlegroups.com
I have a users model being automatically generated by hobo and i created a new resource called "Product". Im trying a simple application like inventory management . 

The association im using 

class Product < ActiveRecord::Base

  hobo_model # Don't put anything above this

  fields do
    item      :name
    timestamps
  end

 belongs_to  :user, :class_name => "User", :creator => true  

   def create_permitted?
    acting_user.signed_up?
  end

  def update_permitted?
    acting_user.signed_up?
  end

  def destroy_permitted?
    acting_user.signed_up?
  end

  def view_permitted?(field)
    acting_user.signed_up?
  end

  and for user 
  
 class User < ActiveRecord::Base

  hobo_user_model # Don't put anything above this

  fields do
    name          :string, :required, :unique
    address       :string
    email_address :email_address, :login => true
    administrator :boolean, :default => false
    timestamps
  end
  
  children :products

  has_many :products, :dependent => :destroy

After i start the application. I logged into testuser1 and tried to create a new product. and im getting a drop down list with  <testuser1> <testuser2> <testuser3> with  <testuser1> selected . 

Can i skip this dropdown from model and not with <fields-list skip="user"> 

Thanks
Vivek 

kevinpfromnm

unread,
Jun 11, 2012, 12:11:17 PM6/11/12
to hobo...@googlegroups.com
The simplest way is to change the create permission so that it only allows the owner to be the creator

def create_permitted?
  user_is? acting_user
end

Hobo will then drop the user field on the form automatically.
Reply all
Reply to author
Forward
0 new messages