Rubymine code completion of model object
Our rails project involves two databases: Postgres and MS sql server.
In the one database case :
When a variable holds a model object, see this RubyMine suggests suitable code completion with created dynamic queries, e.g. find_by_name, find by phone ....
But in model like :
class Customer < ActiveRecord::Base
establish_connection :sqlacc
self.table_name = 'ACC_CODE'
...
the model object from Customer did not get code completion with created dynamic queries, i.e. find_by_code ...
Would somebody know how to get this work ?
Thanks
Please sign in to leave a comment.
Hello Jenifer,
Could you please specify your RubyMine version? In addition, it'd be great if you could provide a minimal project sample for reproduce so that we could understand better the issue.
In addition, if you could share a minimum example of the phrazle project that exhibits the problem, that would be fantastic.
One way to resolve the issue with code completion for dynamic queries in RubyMine when working with a model connected to a secondary database is to ensure that RubyMine is correctly configured and that the necessary gems for MS SQL Server are installed and properly set up.
Here are a few steps that you might find helpful:
1. Ensure Correct Database Gems:
Make sure you have the necessary database adapter gems in your Gemfile. For MS SQL Server, you might be using the tiny_tds and activerecord-sqlserver-adapter gems. Ensure they are added to your Gemfile and run bundle install.
rubyCopy code
gem 'tiny_tds' gem 'activerecord-sqlserver-adapter'
2. Configure Database Connections:
Ensure that the config/database.yml file is correctly configured with the connection details for both PostgreSQL and MS SQL Server. For example:
yamlCopy code
default: &default adapter: postgresql pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> development: <<: *default database: your_postgres_database username: your_username password: your_password sqlacc: adapter: sqlserver database: your_sql_server_database username: your_username password: your_password
3. RubyMine Configuration:
Go to the RubyMine settings/preferences and navigate to the ‘Languages & Frameworks’ -> ‘Ruby SDK and Gems’ section. Make sure that the correct SDK is selected and that the gems are loaded.
4. RubyMine Database Tool Window:
Open the Database Tool Window in RubyMine and ensure that both databases are connected and visible in this window. You may need to add the MS SQL Server manually and configure the connection settings.
5. Model Configuration:
Ensure that the model is correctly configured to establish a connection with the secondary database:
rubyCopy code
class Customer < ActiveRecord::Base establish_connection :sqlacc self.table_name = 'ACC_CODE' #... end
6. Restart RubyMine:
After performing these steps, restart RubyMine to ensure that the changes are applied.
Remember, code completion in IDEs like RubyMine relies heavily on correct project configuration. If the IDE can't properly interpret the project setup, features like code completion might not work as expected.
I've also tried the configuration between the Rubymine and DGME and got 1 error specially on establishing the connection between both nodes.
This should help streamline your code completion experience!