Project has_many Users through

Ruby on Rails tutorial Here is a Ruby on Rails example of adding a join table so that you can create a has_many Users through situation with Projects. This assumes that you already have a Project and a User model. 1. Generate your scaffold: Generating a scaffold here called UserProjects. It has two reference fields … Read more

Add Index to join table with unique checks

Ruby on Rails add index to join table, generate migration 1. make uniqueness index on areas_deals:*This stops the association from being able to be duplicated, but throws an error causing bad UI, we will address that below** 2. Check the schema and make sure you got what you want. We wanted this added: t.index [“area_id”, … Read more

Regex tricks – Change strings to formatted numbers

(regex == regular expressions) There are a few Regex tricks that I use constantly in my javascript stuff to control numbers or variable names. Here are a few examples of Regex in action. Remove non-numeric characters except periods: This will take a string or number and change it to an integer or a float that … Read more