From ebb04676b950ff576e162e3453c9194c932f0171 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Fri, 13 Nov 2015 11:58:37 +1100 Subject: [PATCH] projectionist: add --- projectionist.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ rails-forms.md | 10 +++++++++ rails-models.md | 25 ++++++++++++++++++--- 3 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 projectionist.md diff --git a/projectionist.md b/projectionist.md new file mode 100644 index 000000000..1dcfcac35 --- /dev/null +++ b/projectionist.md @@ -0,0 +1,58 @@ +--- +title: Projectionist +--- + + +```json +/* .projectionist.vim */ +{ + "app/assets/react/components/*.jsx": { + "type": "component", + "template": [ + "import React from 'react'", + "export default {} = React.createClass({ ... })" + ] + } +``` + +### Available options + +```js +{ + "lib/*.rb": { + "type": "lib", /* enables :Elib */ + "alternate": "test/{}_spec.rb", /* for :A */ + "template": [ ... ], + + "path": "include", /* for `gf` i think */ + + "console": "node", /* for :Console */ + "dispatch": "node", /* for :Dispatch (dispatch.vim) */ + "start": "rails server", /* for :Start (dispatch.vim) */ + "make": "node", /* for makeprg */ + } +} + +### Commands + +| Command | Description | +|---------|-------------| +| `:A` | Edit alternate | +| `:A {file}` | Edit file | +|---------|-------------| +| `:AS` | Edit in split | +| `:AV` | Edit in vsplit | +| `:AT` | Edit in tab | +|---------|-------------| +| `:AD` | Replace with template | +|---------|-------------| +| `:Cd` | cd to root | +| `:Cd {path}` | cd to path in root | +| `:Lcd` | cd to root using :lcd | +|---------|-------------| +| `:ProjectDo {cmd}` | run command in root | +{:.shortcuts} + +### Reference + +See [vim-projectionist](https://github.com/tpope/vim-projectionist). diff --git a/rails-forms.md b/rails-forms.md index aacadd76b..5809673f9 100644 --- a/rails-forms.md +++ b/rails-forms.md @@ -138,3 +138,13 @@ radio_button("post", "category", "java") # ``` + +### Reference + +```rb +select(method, choices = nil, options = {}, html_options = {}, &block) + choices == [ ['label', id], ... ] + +submit(value=nil, options={}) +``` + diff --git a/rails-models.md b/rails-models.md index edbdd4172..e00bb3dac 100644 --- a/rails-models.md +++ b/rails-models.md @@ -7,20 +7,39 @@ layout: default ```rb items = Model - .where(first_name: "Harvey") + .where(first_name: 'Harvey') + .where('id = 3') + .where('id = ?', 3) .order(:title) .order(title: :desc) .order("title DESC") - .reorder(:title) # discards other .orders - .rewhere(...) + .reorder(:title) # discards other .order's + .rewhere(...) # discards other .where's .limit(2) .offset(1) .uniq ``` +Advanced: + +```rb + .select(:id) + .select([:id, :name]) + + .group(:name) # GROUP BY name + .group('name AS grouped_name, age') + .having('SUM(price) > 30') # needs to be chained with .group + + .includes(:user) + .includes(user: [:articles]) + + .references(:posts) + # .where("posts.name = 'foo'").references(:posts) +``` + ### [FinderMethods](http://devdocs.io/rails/activerecord/findermethods) ```rb