不读数据库怎么找到 @page
?
DHH 用的是 TextMate。
程序员编辑器都是要靠插件和配置的,不会 google 就哪个都难用。
#17 楼 @liguangsong 私有不看,邮件已删,建议改密码。
#13 楼 @liguangsong 把代码发到 github。
Ruby 必读书。
不要靠猜,看浏览器调试,看静态服务器日志,看应用日志。
找提供私有网络的提供商,例如 https://www.digitalocean.com/company/blog/introducing-private-networking/
自己做的话,就是不接入公网。
不过以前看过分享说 Github 用的语言也不少的,https://hubot.github.com/ 就是用 coffeescript。
为什么说“为什么都说 Devise 很慢?”?
这段代码是在 head 插入 script 引入外部脚本然后立即执行,试试去掉这段代码,在 </body>
前插入
<script src="//static.duoshuo.com/embed.js" async></script>
标题很无聊。
如果你说的是生成 url。
def to_param
"#{first_name}-#{last_name}"
end
定义一个方法不就好了。
def find_by_friendly_id(id)
first_name, last_name = id.split('-')
find_by! first_name: first_name, last_name: last_name
end
#7 楼 @nowherekai 用 memcached 或 redis。
def show
if Rails.cache.increment("login/ip/#{request.ip}", 0, expires_in: 10.minutes).to_i > 3
render :ip_limit
else
# login form
end
end
def create
if Rails.cache.increment("login/ip/#{request.ip}", 1, expires_in: 10.minutes) > 3
render :ip_limit
else
if success
# login
Rails.cache.delete("login/ip/#{request.ip}")
else
# render :show
end
end
end
补充:
发代码不要用截图。
class User
has_many :memberships
has_many :circles, through: :memberships do
# Association Extensions
def status(status)
where(memberships: { status: status })
end
end
end
class Membership
belongs_to :user
belongs_to :circles
end
class Circle
has_many :memberships
has_many :users, through: :memberships
end
# Association
User.first.circles.where(memberships: { status: status})
# Association Extensions
User.first.circles.status(status)
Circle.joins(:memberships).where(memberships: { status: status, user_id: id })
#2 楼 @gztheknot pass