textmate / ruby-on-rails-tmbundle

Ruby on Rails TextMate bundle [Learn it with PeepCode - http://peepcode.com/products/textmate-for-rails-2]
http://groups.google.com/group/rails-textmate
MIT License
15 stars 22 forks source link

"Show DB Schema for Current Class" doesn't work #32

Open yuchan opened 6 years ago

yuchan commented 6 years ago
screen shot 2017-12-16 at 23 05 14

TextMate version: 2.0-rc.4 Ruby version: ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16] Rails version: 5.1.4

I was looking into show_schema.rb and found ruby18. Then, I tried changing it to ruby, but it didn't work.

Recent ruby versions are supporting __dir__, as far as I know.

flyweights commented 5 years ago

I'd like to know, too. Thank you

noniq commented 5 years ago

This command script (written in Ruby) tries to load the current Rails app, so that it can read the #columns_hash data for the selected model. However, because the command also uses TextMate’s own Ruby API, it needs to run using Ruby 1.8 (this API is not yet fully compatible with Ruby 2).

Rails has dropped support for Ruby 1.8 in version 4.0, so this command will fail when run for a Rails app using Rails 4 or newer.

Ideally, this command should be rewritten in a way that does not require loading the Rails app inside the command script. I suppose the commands for accessing and parsing the model’s column data could be executed by shelling out to bin/rails runner "…" instead. This would have the benefit of automatically using the correct Ruby version and respecting all kinds of customizations (preloaders like spring, configuration settings from env vars, …).

Would you like to create a pull request?