The basic goal of Simple Form is to not touch your way of defining the layout
一个故事讲完https - 0 views
71More
plataformatec/simple_form - 0 views
-
Simple Form acts as a DSL and just maps your input type (retrieved from the column definition in the database) to a specific helper method.
- ...68 more annotations...
-
Simple Form generates a wrapper div around your label and input by default, you can pass any html attribute to that wrapper as well using the :wrapper_html option,
-
Simple Form will look at the column type in the database and use an appropriate input for the column
-
give the :disabled option to Simple Form, and it'll automatically mark the wrapper as disabled with a CSS class
-
Collections can be arrays or ranges, and when a :collection is given the :select input will be rendered by default
-
define a to_label method on your model as Simple Form will search for and use :to_label as a :label_method first if it is found
-
configured with a default value to be used on the site through the SimpleForm.country_priority and SimpleForm.time_zone_priority helpers.
-
render a :select input for choosing the :company, and another :select input with :multiple option for the :roles
-
Simple Form will always look for a default attribute translation under the "defaults" key if no specific is found inside the model key
-
Simple Form will fallback to default human_attribute_name from Rails when no other translation is found for labels.
-
translations for labels, hints and placeholders for a namespaced model, e.g. Admin::User, should be placed under admin_user, not under admin/user
-
This difference exists because Simple Form relies on object_name provided by Rails' FormBuilder to determine the translation path for a given object instead of i18n_key from the object itself.
-
The HTML5 extensions include the new field types such as email, number, search, url, tel, and the new attributes such as required, autofocus, maxlength, min, max, step.
-
If you want to have all other HTML 5 features, such as the new field types, you can disable only the browser validation
250 GB/day of logs with Graylog: Lessons Learned - The HFT Guy - 0 views
How to Redirect a Web Page | CSS-Tricks - 0 views
31More
Deploying Rails Apps, Part 6: Writing Capistrano Tasks - Vladi Gleba - 0 views
- ...27 more annotations...
-
SSHKit was actually developed and released with Capistrano 3, and it’s basically a lower-level tool that provides methods for connecting and interacting with remote servers
-
capture(): executes a command and returns its output as a string
-
upload() has the bang symbol (!) because that’s how it’s defined in SSHKit, and it’s just a convention letting us know that the method will block until it finishes.
-
But in order to ensure rake runs with the proper environment variables set, we have to use rake as a symbol and pass db:seed as a string
-
This format will also be necessary whenever you’re running any other Rails-specific commands that rely on certain environment variables being set
-
we’re using the callbacks inside a namespace to make sure Capistrano knows which tasks the callbacks are referencing.
-
When you run cap production deploy, you’re actually calling a Capistrano task called deploy, which then sequentially invokes other tasks
54More
elabs/pundit: Minimal authorization through OO design and pure Ruby classes - 0 views
- ...49 more annotations...
-
in leveraging regular Ruby classes and object oriented design patterns to build a simple, robust and scaleable authorization system
-
authorize would have done something like this: raise "not authorized" unless PostPolicy.new(current_user, @post).update?
-
pass a second argument to authorize if the name of the permission you want to check doesn't match the action name.
-
Instances of this class respond to the method resolve, which should return some kind of result which can be iterated over.
-
scope.where(published: true)
-
verify_policy_scoped to your controller. This will raise an exception in the vein of verify_authorized. However, it tracks if policy_scope is used instead of authorize
-
Having a mechanism that ensures authorization happens allows developers to thoroughly test authorization scenarios as units on the policy objects themselves.
-
Pundit doesn't do anything you couldn't have easily done yourself. It's a very small library, it just provides a few neat helpers.
-
Pundit strongly encourages you to model your application in such a way that the only context you need for authorization is a user object and a domain model that you want to check authorization for.
-
If you have defined an action-specific method on your policy for the current action, the permitted_attributes helper will call it instead of calling permitted_attributes on your controller
-
Given there is a policy without a corresponding model / ruby class, you can retrieve it by passing a symbol
73More
我必须得告诉大家的MySQL优化原理 - 简书 - 0 views
- ...70 more annotations...
-
MySQL关联执行的策略非常简单,它对任何的关联都执行嵌套循环关联操作,即先在一个表中循环取出单条数据,然后在嵌套循环到下一个表中寻找匹配的行,依次下去,直到找到所有表中匹配的行为为止。然后根据各个表匹配的行,返回查询中需要的各个列。
-
最外层的查询是根据A.xx列来查询的,A.c上如果有索引的话,整个关联查询也不会使用。再看内层的查询,很明显B.c上如果有索引的话,能够加速查询,因此只需要在关联顺序中的第二张表的相应列上创建索引即可。
Interviewing a front-end developer - 0 views
16More
MySQL 到底能不能放到 Docker 里跑? - 0 views
- ...12 more annotations...
-
根据这个需求按照我们的资源筛选规则 (比如主从不能在同一台机器、内存配置不允许超卖等等),从现有的资源池中匹配出可用资源,然后依次创建主从关系、创建高可用管理、检查集群复制状态、推送集群信息到中间件 (选用了中间件的情况下) 控制中心、最后将以上相关信息都同步到 CMDB。
6More
How to Test Rails Models with RSpec - Semaphore - 0 views
-
Behaviour-driven Development (BDD) as a software development process is composed of multiple subtechniques.
- ...3 more annotations...
View AllMost Active Members
View AllTop 10 Tags
- 151system
- 133programming
- 102docker
- 101rails
- 89development
- 83devops
- 81kubernetes
- 80javascript
- 77database
- 71ruby
- 68linux
- 64web
- 61server
- 58networking
- 52security
- 49python
- 42mysql
- 42php
- 40framework
- 35performance