Commit 47d5c6ed authored by Shem Gyll's avatar Shem Gyll Committed by Achilleas Pipinellis

Add examples for find_by_sql for groups and projects

parent e46f528a
......@@ -356,6 +356,16 @@ DeployKeysProject.with_write_access.find_each do |deploy_key_mapping|
end
```
### Find projects using an SQL query
Find and store an array of projects based on an SQL query:
```ruby
# Finds projects that end with '%ject'
projects = Project.find_by_sql("SELECT * FROM projects WHERE name LIKE '%ject'")
=> [#<Project id:12 root/my-first-project>>, #<Project id:13 root/my-second-project>>]
```
## Wikis
### Recreate
......@@ -709,6 +719,16 @@ emails.each do |e|
end
```
### Find groups using an SQL query
Find and store an array of groups based on an SQL query:
```ruby
# Finds groups and subgroups that end with '%oup'
Group.find_by_sql("SELECT * FROM namespaces WHERE name LIKE '%oup'")
=> [#<Group id:3 @test-group>, #<Group id:4 @template-group/template-subgroup>]
```
## Routes
### Remove redirecting routes
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment