- 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
import {Controller} from '@hotwired/stimulus' | |
import {Editor} from "@tiptap/core" | |
import {Mention} from "@tiptap/extension-mention"; | |
import StarterKit from "@tiptap/starter-kit" | |
export default class extends Controller { | |
static targets = ['input', 'suggestions'] | |
connect() { | |
this.editor = new Editor({ |
import React from 'react' | |
import axios, { post } from 'axios'; | |
class SimpleReactFileUpload extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state ={ | |
file:null | |
} |
I got tired on creating new files manually for each new post a write so I put together this little command line task with Thor.
It creates a new file in the _posts directory with today’s date, parses the parameters to command as the post’s title and adds that as a slug to the new file. It then writes a default yaml template to the file (as specified in the script).
Running thor jekyll:new New and shiny post
will for example create the file _posts/2012-12-28-new-and-shiny-post.markdown
, populate it with an yaml template and finally open the file in my favorite editor.
Add the following to your Gemfile:
I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api
Rails.application.routes.draw do
constraints subdomain: "api" do
scope module: "api" do
# Compiled source # | |
################### | |
*.com | |
*.class | |
*.dll | |
*.exe | |
*.o | |
*.so | |
# Packages # |
<canvas id="user-icon" width="256" height="256"></canvas> |
Sometimes we need to keep a file in the project but do not want to track the changes, for example the config/configuration file or other setting file.
git
has a solution to do this. First change the file you do not want to be tracked and use the following command.
git update-index --assume-unchanged FILE_NAME
and if you want to track the changes again use this command,
git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream