Pry show methods命令返回意外内容

时间:2015-08-19 19:08:16

标签: ruby-on-rails pry

我正在尝试简单地列出模型的方法。正如你所看到的那样,它会带来一些意外我不确定我到底做错了什么。

    [4] pry(Event):1> ls -m
Object.methods: yaml_tag
ActiveModel::Naming#methods: model_name
ActiveSupport::Benchmarkable#methods: benchmark
ActiveSupport::DescendantsTracker#methods: descendants  direct_descendants
ActiveRecord::ConnectionHandling#methods: clear_cache!  connection_id  connection_id=  mysql2_connection
ActiveRecord::QueryCache::ClassMethods#methods: cache  uncached
ActiveRecord::Querying#methods: 
  any?          distinct     find_each              forty_two   last     pluck       take      
  average       eager_load   find_in_batches        forty_two!  last!    preload     take!     
  calculate     except       find_or_create_by      fourth      limit    readonly    third     
  count         exists?      find_or_create_by!     fourth!     lock     references  third!    
  count_by_sql  fifth        find_or_initialize_by  from        many?    reorder     uniq      
  create_with   fifth!       first                  group       maximum  rewhere     unscope   
  delete        find         first!                 having      minimum  second      update    
  delete_all    find_by      first_or_create        ids         none     second!     update_all
  destroy       find_by!     first_or_create!       includes    offset   select      where     
  destroy_all   find_by_sql  first_or_initialize    joins       order    sum       
ActiveModel::Translation#methods: human_attribute_name
ActiveRecord::Translation#methods: i18n_scope  lookup_ancestors
ActiveRecord::DynamicMatchers#methods: respond_to?
ActiveRecord::Explain#methods: collecting_queries_for_explain  exec_explain
ActiveRecord::Enum#methods: enum
ActiveRecord::Delegation::DelegateCache#methods: initialize_relation_delegate_cache  relation_delegate_class
ActiveRecord::Core::ClassMethods#methods: ===  arel_engine  arel_table  generated_association_methods  inspect
ActiveRecord::Persistence::ClassMethods#methods: create  instantiate
ActiveRecord::ReadonlyAttributes::ClassMethods#methods: attr_readonly  readonly_attributes
ActiveRecord::ModelSchema::ClassMethods#methods: 
  column_names  content_columns         inheritance_column=       reset_sequence_name  table_exists?
  column_types  decorate_columns        initialize_attributes     reset_table_name     table_name=  
  columns       full_table_name_prefix  quoted_table_name         sequence_name    

如何显示此特定型号的方法?

1 个答案:

答案 0 :(得分:2)

您可以在ModelName控制台中使用methodspry,它将为您提供Model的所有方法。 所以,对你来说,它是:

ls Event.methods

有关更多类似命令,请参阅here