gem Reason: pass responsibility to controllers instead of models def post_params if @current_user.admin? params.require(:post).permit(:title, :body, :visible) else params.require(:post).permit(:title, :body) end end Wednesday, 9 October, 13
the benefit of not throwing away the browser instance and recompiling all of it for every page Problem: https:/ /github.com/kossnocorp/jquery.turbolinks “page:load” event $(function(){ console.log(“Document ready”); }); Wednesday, 9 October, 13
}, { "todolists/todolist": [ "comments/comment" ] } ] How it works MD5 the template file itself and all of its dependencies. It'll change if you change either the template or any of the dependencies, and thus allow the cache to expire automatically. Wednesday, 9 October, 13
PATCH/PUT /posts/1.json def update @post = Post.find(params[:id]) end end Better naming for the action put - overwrite the existing record patch - update partial information API requests can use PUT or PATCH Wednesday, 9 October, 13
LIMIT 1 # Rails 4 > Post.first SELECT “posts”.* FROM “posts” ORDER BY “posts”.”id” ASC LIMIT 1 > Post.where.not category_ids: [5,7] SELECT “posts”.* FROM “posts” WHERE (“posts”.”category_id” NOT IN (5,7)) Wednesday, 9 October, 13
options end concern :image_attachable do resources :images, only: index end resources :posts, concerns: [:commentable, :image_attachable] do resource :video, concerns: :commentable end Wednesday, 9 October, 13