You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are plenty of tips out there for using ActiveRecord without Rails, but I was having trouble synthesizing all of the relevant information. Once I got things working, I decided to bring together all of the important pieces I used.
given a single intensity value and range parameters, return a hex string for color on red-green scale
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Linking two ActiveRecord models with multiple different foreign keys
Linking Two ActiveRecord Models with Multiple Foreign Keys
My colleague and I have been working on a project for a client in the real estate industry. The product we're creating is a Rails app that tracks apartment listings, and one of the key features is that our client's agents must be able to create and edit "specials" that modify the prices of existing listings. There are many different types of specials: those that simply award a credit upon move-in; those that are relative to the rent of the property, such as one month free; and those that only apply during a particular date range, either for the signing of the lease or for the actual move-in date.
Any given special can apply to any number of matching listings, but any given listing can only have one special. We want to be able to retrieve the special linked to a particular listing quickly and easily, so this leads to a pretty straightforward association:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters