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
| User |> User.search("mitch") |> Repo.all | |
| # [debug] SELECT u0."id", u0."username" FROM "users" AS u0 WHERE (u0."name" % $1) ORDER BY similarity(u0."name", $2) DESC ["mitch", "mitch"] (1.9ms) | |
| [%User{__meta__: %Ecto.Schema.Metadata{source: "users", state: :loaded}, | |
| username: "mitch"}, | |
| %User{__meta__: %Ecto.Schema.Metadata{source: "users", state: :loaded}, | |
| username: "mitch3"}] |
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
| defmodule User do | |
| use Ecto.Model | |
| schema "users" do | |
| field :username, :string | |
| end | |
| def search(query, search_term) do | |
| from(u in query, | |
| where: fragment("? % ?", u.username, ^search_term), |
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
| defmodule Repo.Migrations.UserSearch do | |
| use Ecto.Migration | |
| def up do | |
| execute "CREATE extension if not exists pg_trgm;" | |
| execute "CREATE INDEX users_username_trgm_index ON users USING gin (username gin_trgm_ops);" | |
| end | |
| def down do | |
| execute "DROP INDEX users_username_trgm_index;" |
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
| defmodule User do | |
| use Ecto.Model | |
| schema "users" do | |
| field :username, :string | |
| end | |
| end |
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
| after_connect = proc do |connection| | |
| connection.query("UPDATE items set text='testing' where id = 34;") | |
| end | |
| Sequel::Model.db = Sequel.connect(ENV['DATABASE_URL'], after_connect: after_connect) |
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
| module Review | |
| module Account | |
| class ReviewImagesController < ApplicationController | |
| def create | |
| puts params | |
| render :json => {:stuff=>params}.to_json | |
| end | |
| end |
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
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
| <title>Padrino Admin</title> | |
| <%= stylesheet_link_tag :base, "themes/default/style" %> | |
| </head> | |
| <body> | |
| <div id="container"> | |
| <div id="box"> |
NewerOlder