This commit is contained in:
Rico Sta. Cruz 2016-04-25 15:55:29 +08:00
parent 22cc927a85
commit 414d1c3ac5
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
5 changed files with 77 additions and 45 deletions

View File

@ -14,33 +14,52 @@ category: JavaScript libraries
## Config
files:
javascripts: # or 'stylesheets' or 'templates'
order:
before: [ 'normalize.css' ]
after: [ 'helpers.css' ]
```js
module.exports = {
files: {
javascripts: { # or 'stylesheets' or 'templates'
order: {
before: [ 'normalize.css' ],
after: [ 'helpers.css' ],
joinTo: 'app.js'
joinTo:
'js/app.js': /^app/
'js/vendor.js': /^vendor/
pluginHelpers: 'js/vendor.js'
joinTo: 'app.js',
joinTo: {
'js/app.js': /^app/,
'js/vendor.js': /^vendor/
},
pluginHelpers: 'js/vendor.js'
}
}
paths:
public: 'public' # where to compile
watched: ['app','test','vendor'] # what to monitor
paths: {
public: 'public', # where to compile
watched: ['app','test','vendor'], # what to monitor
}
modules:
wrapper: 'amd'
definition: 'amd'
nameCleaner: (path) -> path.replace /^app\//, ''
modules: {
wrapper: 'amd',
definition: 'amd',
nameCleaner: (path) => path.replace(/^app\//, '')
}
# brunch b --apply production
overrides:
production:
optimize: true
sourceMaps: false
plugins: autoReload: enabled: false
npm: { styles, globals }
plugins: {
sass: { ... }
}
// brunch w --apply testing
// BRUNCH_ENV=testing brunch build
overrides: {
production: {
optimize: true,
sourceMaps: false,
plugins: { autoReload: { enabled: false } }
}
}
onCompile: (files, assets) => { ... }
```
## Plugins
@ -53,11 +72,11 @@ category: JavaScript libraries
## Extensions
Compile to JS/CSS
Compile to CSS
* stylus-brunch
* coffee-script-brunch
* less-brunch
* sass-brunch
Compile to HTML
@ -75,4 +94,4 @@ Etc
## References
* https://github.com/brunch/brunch/blob/master/docs/config.md
* <https://github.com/brunch/brunch/blob/master/docs/config.md>

View File

@ -19,4 +19,3 @@ Use `{{ contents }}` to bring it out
Engines:
* swig (like liquid)

View File

@ -110,6 +110,11 @@ category: Rails
add_index :accounts, [:branch_id, :party_id, :surname],
:order => {:branch_id => :desc, :part_id => :asc}
### In console
Use `ActiveRecord::Migration`.
ActiveRecord::Migration.add_index :posts, :slug
### References
* http://apidock.com/rails/ActiveRecord/ConnectionAdapters/SchemaStatements/add_index

View File

@ -3,9 +3,10 @@ title: Routes
category: Rails
---
### Multiple resources
## Multiple resources (`resources`)
resources :books
# PhotosController:
# index => GET /photos
# new => GET /photos/new
@ -19,16 +20,32 @@ category: Rails
# new_book_path
# book_path(id)
# edit_book_path(id)
#
### Custom actions
resources :photos do
member { get 'preview' } # /photo/1/preview
get 'preview', on: :member # (..same as the first)
collection { get 'search' } # /photos/search
get 'preview', on: :member # (..same as the first)
end
### Single resource
### Options
resources :photos,
path_names: { new: 'brand_new' } # /photos/1/brand_new
path: 'postings' # /postings
only: :index
only: [:index, :show]
except: :show
except: [:index, :show]
shallow: true # also generate shallow routes
shalow_path: 'secret'
shallow_prefix: 'secret'
## Single resource (`resource`)
resource :coder
# CodersController:
@ -39,7 +56,7 @@ category: Rails
# update => PUT /coder
# delete => DELETE /coder
### Matching
## Matching (`match`)
match 'photo/:id' => 'photos#show' # /photo/what-is-it
match 'photo/:id', id: /[0-9]+/ # /photo/0192

View File

@ -56,22 +56,14 @@ end
# spec/requests/*.rb
describe "home page" do
it "displays the user's username after successful login" do
user = User.create!(:username => "jdoe", :password => "secret")
get "/login"
assert_select "form.login" do
assert_select "input[name=?]", "username"
assert_select "input[name=?]", "password"
assert_select "input[type=?]", "submit"
end
post "/login", username: "jdoe", password: "secret"
expect(response.status).to eql 200
# capybara
expect(page).to have_selector(".header .username", :text => "jdoe")
expect(response).to redirect_to(...)
expect(response).to render_template(:show)
expect(response.body).to include 'hello'
follow_redirect!
end
end
```