- You MUST NOT try and generate a Rails app from scratch on your own by generating each file. For a NEW app you MUST use
rails new
first to generate all of the boilerplate files necessary. - Create an app in the current directory with
rails new .
- Use Tailwind CSS for styling. Use
--css tailwind
as an option on therails new
call to do this automatically. - Use Ruby 3.2+ and Rails 8.0+ practices.
- Use the default Minitest approach for testing, do not use RSpec.
- Default to using SQLite in development.
rails new
will do this automatically but take care if you write any custom SQL that it is SQLite compatible. - An app can be built with a devcontainer such as
rails new myapp --devcontainer
but only do this if requested directly. - Rails apps have a lot of directories to consider, such as app, config, db, etc.
- Adhere to MVC conventions: singular model names (e.g., Product) map to plural tables (products); controllers are plural.
- Guard against incapable browsers accessing controllers with `allo
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
// This helper file provides a consistent API for testing Stimulus Controllers | |
// | |
// Use: | |
// import { getHTML, setHTML, startStimulus } from './_stimulus_helper'; | |
// import MyController from '@javascripts/controllers/my_controller'; | |
// | |
// beforeEach(() => startStimulus('my', MyController)); | |
// test('should do something', async () => { | |
// await setHTML(`<button data-controller="my" data-action="my#action">click</button>`); | |
// |
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
class Cosine | |
def initialize vecA, vecB | |
@vecA = vecA | |
@vecB = vecB | |
end | |
def calculate_similarity | |
return nil unless @vecA.is_a? Array | |
return nil unless @vecB.is_a? Array | |
return nil if @vecA.size != @vecB.size |
This is part of a set of visualisation that try to improve the Barclay's bike distribution in London. Visualizing the map of the London Tube is the first step to understand any correlation with bikes usage.
The technical aim I tried to achieve, is a very simple codebase that enables interaction (such as zooming) for later data analysis.
I have been using RandomETC's idea. However, in order to support scaling and to have a more structured code-base, most of the code has been re-written.