Skip to content

Instantly share code, notes, and snippets.

View kossoff's full-sized avatar
🏠
Working from home

Anthony kossoff

🏠
Working from home
View GitHub Profile
@abhilashak
abhilashak / nested_content_snippet.rb
Last active July 15, 2023 16:10 — forked from bunnymatic/nested_content_snippet.rb
Nested content tags in rails 5 view helpers
View nested_content_snippet.rb
# because i can never remember exactly how and when to use concat
# when building content in helpers
def nested_content
content_tag 'div' do
concat(content_tag 'span', 'span block')
concat(tag 'br')
concat(link_to 'root link', root_path)
concat(tag 'br')
concat(link_to('#') do
concat(content_tag 'h2', 'Head \'em off')
@cdesch
cdesch / rails_generator_cheat_sheet.md
Last active September 19, 2023 16:52
Rails Generator CheatSheet
View rails_generator_cheat_sheet.md

Cheat Sheets are greate but they are not a substitute for learning the framework and reading the documentation as we most certainly have not covered every potential example here. Please refer to the Rails Command Line Docs for more information.

Command Line Generator Info

Reference

You can get all of this information on the command line.

rails generate with no generator name will output a list of all available generators and some information about global options. rails generate GENERATOR --help will list the options that can be passed to the specified generator.

@AlexVKO
AlexVKO / add_unaccent_to_postgres
Created September 19, 2015 19:48
Adding extensions to Postgresql database with Rails
View add_unaccent_to_postgres
The default Postgresql installation on Mac OS X using homebrew includes a single extension - plpgsql (PL/pgSQL procedural language) but there are a number of them available in the lib directory (/usr/local/Cellar/postgresql/9.2.1/lib on my machine)
To install an extension into the database, the easiest way I found was to open a database console using the 'rails db' command and then create it directly. I have seen mention of doing this in a Rails migration but this did not work for me.
Note that an extension is installed in a specific database, rather than being added to all databases.
The command to list the installed extensions is '\dx'
$ rails db
psql (9.2.1)
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active October 4, 2023 15:01
Useful PostgreSQL Queries and Commands
View postgres_queries_and_commands.sql
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@amejiarosario
amejiarosario / rails_migration_cheatsheet.md
Created June 18, 2012 21:40
Rails Migration - Cheatsheet
@rstacruz
rstacruz / index.md
Last active April 12, 2023 08:55
Rails models cheatsheet
View index.md