Rails中有很多验证码插件,还有许多类型的防止垃圾邮件和泛滥的解决方案.所以这不仅仅是Rails的问题.
我们来看看我们有哪些类型的插件:
1.经典图像验证码(zendesk的Captcha,Simple_captcha,Validates_captcha,winton的Captcha,Raptcha).
正:
负:
2. ReCaptcha(Recaptcha,Rack-recaptcha).
正:
负:
3.蜜罐(Negative-captcha,Trap_door,Reverse_captcha,Honeypot-captcha,Bouncy_bots,invisible_captcha).
正:
负:
4.文本库(Humanizer,Brain_buster,Gotcha).
正:
负:
5.其他(Acts_as_snook)
正:
负:
不知道有没有,因为它很不寻常.但我认为这可能会导致水浸问题,因为它可能需要在某些时候进行调节.
6.类似Akismet的解决方案(不知道它们的效率).
正:
负:
我也应该对我的网站说几句话.用户只有在ajax请求之后才会看到受保护的表单(例如,在将某些内容放入购物车之后).现代机器人是否有能力执行ajax请求和存储cookie?
我在生产服务器上使用Rails,Passenger(均为3.0.5)和Nginx.当我听说,Rails的应该显示public/404.html或public/500.html代替像开发错误的ActiveRecord::RecordNotFound或Unknown action但这并没有发生.我试图删除config.ru文件并在nginx.conf中设置rack_env或rails_env,但没有任何帮助.
这是我的nginx.conf:
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /home/makk/.rvm/gems/ruby-1.9.2-p0/gems/passenger-3.0.5;
passenger_ruby /home/makk/.rvm/bin/passenger_ruby;
#passenger_ruby /home/makk/.rvm/wrappers/ruby-1.9.2-p0/ruby;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /home/makk/projects/1server/deploy/current/public;
index index.html index.htm;
passenger_enabled on;
rack_env production;
recursive_error_pages on;
if (-f /home/makk/projects/1server/maintenance.html) {
return 503;
}
error_page 404 /404.html;
error_page 500 502 504 /500.html;
error_page 503 @503;
}
location @503 {
error_page 405 = /maintenance.html; …Run Code Online (Sandbox Code Playgroud) 我使用Rails3,JQuery和will_paginate gem来制作远程分页链接.已知的解决方案是:
$('.pagination a').live('click',function (){
$.getScript(this.href);
return false;
});
Run Code Online (Sandbox Code Playgroud)
使用此代码,我得到如下链接:http://localhost:3000/products?_=1300468875819&page=1或http://localhost:3000/products?_=1300468887024&page=2.所以小问题是:这个奇怪的参数是什么_=1300468887024(看起来像Unix时间).它的目的是什么?据我所知,这可能会导致搜索爬虫出现问题.
我在分页链接上使用Ben Almans的jQuery BBQ和jQuery hashchange插件.两者都在Opera和Firefox中按预期工作,但在IE 8中没有(令人惊讶,是吧?).IE也适用于ajax,后退按钮和hashchange,但是当我单击重新加载按钮并显示原始ajax响应而不是在先前加载的页面中运行它时失败.
所以这是我的丑陋代码和我试图在我的分页中实现的功能的一些解释:
1)搜索引擎友好链接(服务器根据客户端的javascript可用性响应html或js).
2)打开JS时使用动态可更改的URL(使用"#"符号).
3)历史和后退按钮支持.
4)最小化双重请求(如果使用html页面加载相同内容,则不要发出ajax请求).
JS:
$(function ($) {
if (ajax_init) {
$('.pagination a').live("click", function () {
$.bbq.pushState({page: $.deparam.querystring($(this).attr('href')).page});
return false;
});
$(window).bind("hashchange", function(e) {
var anchor = $.deparam.fragment().page;
var query = $.deparam.querystring().page;
if (ajax_load(anchor, query)) {
$(ajax_div).css('opacity', '0.4');
$(ajax_div + '-processing').removeClass('hidden');
$.ajax({
type: 'GET',
url: $.param.querystring('', {page: anchor}),
dataType: 'script',
cache: false
});
}
});
$(window).trigger('hashchange');
}
});
function ajax_load(anchor, query) {
if ((anchor && anchor !== query && !(!query && anchor …Run Code Online (Sandbox Code Playgroud) 我正在使用Rails代码获得非常难看的SQL查询,如下所示:
Facility.includes(:type, :owner_building, :delegated_building, keeper_building, :owner_user, :keeper_user).order('users.name ASC').all
Run Code Online (Sandbox Code Playgroud)
它产生:
SELECT `facilities`.`id` AS t0_r0, `facilities`.`name` AS t0_r1, `facilities`.`brand` AS t0_r2, `facilities`.`desc` AS t0_r3, `facilities`.`type_id` AS t0_r4, `facilities`.`owner_building_id` AS t0_r5, `facilities`.`keeper_building_id` AS t0_r6, `facilities`.`delegated_building_id` AS t0_r7, `facilities`.`owner_user_id` AS t0_r8, `facilities`.`keeper_user_id` AS t0_r9, `buildings`.`id` AS t1_r0, `buildings`.`name` AS t1_r1, `buildings`.`address` AS t1_r2, `buildings`.`created_at` AS t1_r3, `buildings`.`updated_at` AS t1_r4, `buildings`.`comments` AS t1_r5, `delegated_buildings_facilities`.`id` AS t2_r0, `delegated_buildings_facilities`.`name` AS t2_r1, `delegated_buildings_facilities`.`address` AS t2_r2, `delegated_buildings_facilities`.`created_at` AS t2_r3, `delegated_buildings_facilities`.`updated_at` AS t2_r4, `delegated_buildings_facilities`.`comments` AS t2_r5, `keeper_buildings_facilities`.`id` AS t3_r0, `keeper_buildings_facilities`.`name` …Run Code Online (Sandbox Code Playgroud) 我正在我的应用程序中实现aсtive_shipping插件功能.我有来自fedex的测试帐户,并试图获得一些运费,如插件的自述文件中所示:
fedex = FedEx.new(:login => '***', :password => '***', :key => '***',
:account => '510087569', :meter => '100054531')
response = fedex.find_rates(origin, destination, packages)
Run Code Online (Sandbox Code Playgroud)
此请求导致错误: ActiveMerchant::Shipping::ResponseError (ERROR - 1000: Authentication Failed)
此外,我对所有API密钥(DHL,UPS等)感到困惑.我是否可以为每个运营商在不同的应用程序中使用相同的帐户密钥,还是应该为每个应用程
ajax ×1
captcha ×1
fedex ×1
flooding ×1
hashchange ×1
jquery ×1
jquery-bbq ×1
left-join ×1
mysql ×1
parameters ×1
passenger ×1
plugins ×1
production ×1
shipping ×1
spam ×1