2

I am working with a gem in my Rails project and I am modifying the gem locally.

In my Gemfile, I have:

gem 'ancestry', path: '/Users/me/.rvm/gems/ruby-2.1.5@test_tree_app/bundler/gems/ancestry-eb5a3e448112'

When I run bundle I get this:

Using ancestry 2.1.4 from source at /Users/me/.rvm/gems/ruby-2.1.5@test_tree_app/bundler/gems/ancestry-eb5a3e448112

I have opened this file and added the following two methods in there:

def parents=(parents)
  write_attribute(self.base_class.ancestry_column, 
                          if parents.nil? 
                            nil 
                          else 
                            parents.map(&:child_ancestry)
                          end
                 )
end

def test_method
  "test"
end

Please ignore indentations for now, it makes it easier to read.

Anyway, in my Rails console, when I try to access both of these methods they are not there.

Specifically, tab complete shows me this:

4] pry(main)> r
=> #<Node id: 36, family_tree_id: 2, created_at: "2015-01-28 23:19:28", updated_at: "2015-01-28 23:19:28", name: "Mesty", ancestry: "13/35", ancestry_depth: 0, max_tree_depth: 0>
[5] pry(main)> r.p
r.parent=                                 r.persisted?                              r.pretty_print_instance_variables
r.parent_id                               r.pluralize_table_names                   r.previous_changes
r.parent_id=                              r.pluralize_table_names?                  r.primary_key_prefix_type
r.parent_ids                              r.populate_with_current_scope_attributes  r.primary_key_value
r.parents                                 r.presence                                r.private_methods
r.partial_writes                          r.presence_in                             r.protected_methods
r.partial_writes?                         r.present?                                r.pry
r.path                                    r.pretty_inspect                          r.psych_to_yaml
r.path_conditions                         r.pretty_print                            r.public_method
r.path_ids                                r.pretty_print_cycle                      r.public_methods
r.perform_validations                     r.pretty_print_inspect                    r.public_send
[5] pry(main)> r.t
r.table_name_prefix                       r.to_json_with_active_support_encoder     r.toggle
r.table_name_prefix?                      r.to_json_without_active_support_encoder  r.toggle!
r.table_name_suffix                       r.to_key                                  r.touch
r.table_name_suffix?                      r.to_model                                r.transaction
r.taint                                   r.to_param                                r.transaction_include_any_action?
r.tainted?                                r.to_partial_path                         r.transaction_record_state
r.tap                                     r.to_query                                r.trust
r.time_zone_aware_attributes              r.to_s                                    r.try
r.timestamped_migrations                  r.to_xml                                  r.try!
r.to_enum                                 r.to_yaml                                 
r.to_json                                 r.to_yaml_properties                      

Notice that neither test_method nor parents= are listed in my list of available methods in my console.

I have exited the console, ran bundle again and reopened console and haven't gotten anywhere.

marcamillion
  • 32,933
  • 55
  • 189
  • 380

1 Answers1

3

Rails 4.1 comes with Spring, an application preloader that caches certain files, including gems.

You can stop Spring manually to force a refresh of all files:

$ spring stop
$ rails c
Stefan
  • 109,145
  • 14
  • 143
  • 218