netflower / guides Goto Github PK
View Code? Open in Web Editor NEWStyle Guides
Style Guides
Finished first draft
Finished first draft. Might add some examples in a separate file.
It's probably my fault we have this in our code, so I'll just make the first step to stop us from doing it in the future.
I started to put queries in before_actions
because it looked DRY to me. For example instead of writing
class UsersController < ApplicationController
def show
@user = User.find(params[:id])
end
def edit
@user = User.find(params[:id])
end
end
I wrote
class UsersController < ApplicationController
before_action :find_user, only: [:show, :edit]
def show
end
def edit
end
private
def find_user
@user = User.find(params[:id])
end
end
There are many problems with this.
before_filter
.I found a good blog post, which get's into this in way more depth - before_action an anti-pattern?.
For me, the ideal would probably be to use the before_action
as they were first intended as a filter for authorisation and such (hence the name before_filter
) and move the queries into the actions.
class UsersController < ApplicationController
def show
@user = find_user
end
def edit
@user = find_user
end
private
def find_user
User.find(params[:id])
end
end
Any thoughts?
We should decide on a standard for all our JSON APIs.
The two big ones would be JSON API and HAL.
As the JSON API site points out:
By following shared conventions, you can increase productivity, take advantage of generalized tooling, and focus on what matters: your application.
For pagination we already looked at HAL but I think JSON API seems a lot more Rails-ish and is designed by the creator of Ember.js, which would probably make Ember easier if we were use it in the future.
Furthermore, from the JSON API site: Why not use the HAL specification?.
Finished first draft.
Finished first draft.
Finished first draft.
Finished first draft.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.