Thoughts, information and reflections about technology

sql

Rails – What to do check your date searches are not showing the results you expect.

Some dates will need to be stored in a date time format.  This does not pose a problem when you are searching for dates equal to or greater than a specific date. You also avoid problems if you are storing dates in a date format.

However, if you search for a date less than or equal to a specific date using a datetime column, your results do not include that date. In other words, if you set up a search to show you everything where the date in question was less than or equal to 3/25/2016 you would not get any records where the date was 3/25/2016.

Continue reading

Accessing an external sql database from a rails app where the schema prefix differs from the schema prefix used for the app’s tables.

This covers a situation where you need to have rails access an external sql database other than the database used for the application. For example, you might need to pull information from one table to populate fields in your current application.  This is further complicated if your application is using a schema prefix.

1. Set a database connection in config/database.yml. You need to set schema_search_path especially if the external sql table is using a schema prefix other than the schema prefix used by the application. Continue reading

Contact me
Archives
Categories