Cheers, Thanks for that. Certainly a better option than constantly updating never_shows. :)
On Jun 24, 2:19 am, Bryan Larsen <[email protected]> wrote: > To keep it DRY, I'd define a view_permitted_helper in your base class > that could be called from view_permitted? in your subclasses with the > list of allowable attributes. If I understand your question correctly, > that should achieve your goals. > > cheers, > Bryan > > > > Hamilton wrote: > > Got STI working nicely. > > However I only want certain fields to show up in forms, views, etc... > > If I used never_show, I would need to update virtually all subclasses > > never_show to exclude fields form view / edit, etc... > > Is there a show_only or something. > > So I have > > class Item < ActiveRecord::Base > > > hobo_model # Don't put anything above this > > > fields do > > #General for all subclasses > > name :string #name of the item. Might be used in LineItem > > code:string #code of the item. Used in LineItem > > timestamps > > inactive:boolean #if this item is inactive or not. If inactive > > then no listed in Store, etc... Also not > > description:text #general description of the item. Used in > > LineItem > > discount_rate:decimal #the rate of discount applied > > is_percentage:boolean > > sti_type :string > > end > > > set_inheritance_column :sti_type > > > In ItemDescription > > > class ItemDescription < Item > > > never_show :code, discount_rate, is_percentage > > > def view_permitted?(field) > > true > > > end > > end > > > There will be more subclasses of Item and a lot more fields in Item. > > I just want to say in ItemDescription only use / show these certain > > fields. I. E the opposite of never_show. That way when new fields are > > added to Item, I only need to update certain subclasess. > > > Help if you can :) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
