- Active Record Query Interface (http://guides.rubyonrails.org/active_record_querying.html), concretely:
- Finding elements
- Where
- Relations
- Scopes
- CRUD
- Extra Active Record articles:
- (http://guides.rubyonrails.org/migrations.html)
This file contains 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.where(signed_up_at: nil).each do |user| | |
if user.oauth_token.present? then | |
user.signed_up_at = user.updated_at | |
user.save | |
end | |
end |
This file contains 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
SELECT | |
'DROP TABLE '||c.relname ||' CASCADE;' | |
FROM pg_catalog.pg_class c | |
JOIN pg_catalog.pg_roles r ON r.oid = c.relowner | |
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace | |
WHERE c.relkind IN ('r','') | |
AND n.nspname NOT IN ('pg_catalog', 'pg_toast') | |
AND pg_catalog.pg_table_is_visible(c.oid) | |
ORDER BY 1; |
This file contains 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 EnglishStudentsController < ApplicationController | |
def update | |
@english_student = User.find(params[:id]) | |
respond_to do |format| | |
if @english_student.update_attributes(english_student_params) | |
format.json { render json: { message: "Student updated successfuly" } } | |
else | |
format.json { render json: { message: "Student could not be updated" } } | |
end |
- What are nested forms?
- Forms that allow you to save information not only for a base element, but for related elements of the main element
- Someone is asking for a SalesOrder Form in which the client name can be set (as plain text)
- What is required to accomplish that?
Since git allows you to run scripts as if they were git commands, this will show how to create a command for creating a pull request from the terminal.
- Create a file with the following name "git-pull-request", we can put it inside ~/.git/extensions for instance. Add the following content to the file
#!/usr/local/bin/bash
repo=`git remote -v | grep -m 1 "(push)" | sed -e "s/.*github.com[:/]\(.*\)\.git.*/\1/"`
branch=`git name-rev --name-only HEAD`
echo "... creating pull request for branch \"$branch\" in \"$repo\""
open https://github.com/$repo/pull/new/$branch