Native Mac app, autocomplete helper for Rails projects that pulls data from model files.
This app will accept a project folder and load the files located in /app/models/ and search for:
- Methods and self.methods, found by lines that begin with "def "
- Properties, found by the schema information produced by the Annotate gem
- Assocations, found by lines beginning with the various Rails association types
- Scopes, found by lines beginning with "scope "
- Enums, found by lines beginning with "enum "
You can also set up custom snippet sets to autocomplete whatever you'd like. With the app focused, press Command-N to open the snippets window to create sets of snippets.
- Snippet sets will be listed among the models in the main autocomplete window
- Each snippet set contains snippets that, when selected, will autocomplete just like model atrributes
This is a very rudimentary autocomplete app used for internal purposes. There are many limitations including:
- It doesn't search any folders besides the main app/models/ folder (and its subfolders if you have Deep checked)
- It's Mac-only but could possibly be modified to work on Windows if you feel like dealing with declares
- There will be many false positives/negatives for method/property/association matches since we didn't spend a ton of time accounting for different formats
- It's intended for Rails 6.x
- Download the compiled Mac App from the latest GitHub release
- Annotate gem is required in your Rails project so this app can pull property values from the model.rb files.
- You'll need to go into System Preferences > Security & Privacy > Privacy > Accessibility, unlock the pane with your system admin password, and drag and drop RailsAutoCompleteHelper.app into the list. After installing each new version or if you're having any issues, you might also have to go back in here and toggle it on and off multiple times since it seems very inconsistent and unreliable.
- You will also need to allow System Preferences > Security & Privacy > Privacy > Automation > RailsAutoCompleteHelper > System Events.
- Launch the RailsAutoCompleteHelper.app and leave it running in the background. If you're using VSCode you can create a task to automatically launch this app when the Project folder is opened.
- Press Control-` to bring the app to the front to start typing your model name. Select a model to start filtering through properties/methods/associations for the model. Select a property/method/association and the app will attempt to send exactly that property's full name to the last active app, via Applescript.
- Press Escape a bunch to hide the app.
- Press Command-1 while the app is active to clear all input and start you with a blank field.
- Press Command-R to reload all models/functions/properties/associations for the project. The app will automatically do this every 3 minutes.
- Press Shift-Return with an item selected to open its definition file in VSCode, as long as you have the VSCode CLI installed.
- Press Command-N to open the snippets editing window. Snippet sets are shown along with your models, and can be used to group and autocomplete snippets.
- Press Command-O to change the current directory of snippet sets. This needs to be set in order to add snippets as they are all saved to text files. You can keep multiple directories with different groups of snippet sets for different purposes.
- Xojo IDE was used to create the app and is required to modify/build
- MBS Plugin is required for several of the functions in the app
- In the App.open event you'll need to create your own registration process for MBS, as we've .gitignored our registration class to prevent sharing of MBS credentials.