我有一个非常奇怪的问题,我的资产在开发中的速度非常慢(每个文件10秒),而这只发生在Chrome(17.0.963.79)中.在Firefox中一切正常.我的设置:
webrick到mongrel和thin使用rails-dev-tweaks gem将缓存类设置为true和false.这一切都没有帮助,我坚持为什么它的工作只在chrome中运行缓慢而不在Firefox中?这也是操作系统的新设置,也许我错过了一些东西,谢谢!UPD.如果这个初始请求(例如来自新标签)都顺利进行.如果我正在刷新页面请求接近2分钟.我只是无法绕过这个问题:(
我想通过Facebook测试我的登录信息.我使用纯粹的omniauth,没有设计.我检查维基页面并执行以下操作:
请求规格的助手
module IntegrationSpecHelper
def login_with_oauth(service = :facebook)
visit "/auth/#{service}"
end
end
Run Code Online (Sandbox Code Playgroud)
spec_helper.rb
RSpec.configure do |config|
config.include IntegrationSpecHelper, :type => :request
end
Capybara.default_host = 'http://example.org'
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:facebook, {
:provider => 'facebook',
:uid => '12345',
:user_info => {
:name => 'dpsk'
}
})
Run Code Online (Sandbox Code Playgroud)
我的规格
require 'spec_helper'
describe 'facebook' do
it "should login with facebook", :js => true do
login_with_oauth
visit '/'
page.should have_content("dpsk")
end
end
#OmniAuth routes
match "/auth/:provider/callback" => "sessions#create"
match "/signout" => "sessions#destroy", :as => :signout
match …Run Code Online (Sandbox Code Playgroud) 我正在Grape gem的帮助下构建XML API.为API操作构建XML的最佳方法是什么?由于Grape没有使用标准轨道控制器,我无法使用views/../xml.builder.你有什么建议?也许有一些构建xml api的最佳实践?
我在Rails模型中添加了自定义属性设置器,在其中添加了验证错误。但是,当记录属性被更新时,结果返回“ true”,这让我有些困惑。有什么提示如何在自定义设置器中使用验证错误?
模型:
class Post < ActiveRecord::Base
attr_accessible :body, :hidden_attribute, :title
def hidden_attribute=(value)
self.errors.add(:base, "not accepted")
self.errors.add(:hidden_attribute, "not_accepted")
write_attribute :hidden_attribute, value unless errors.any?
end
end
Run Code Online (Sandbox Code Playgroud)
控制台输出:
1.9.3p194 :024 > Post.last
Post Load (0.2ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" DESC LIMIT 1
=> #<Post id: 1, title: "asdsaD", body: "la", hidden_attribute: nil, created_at: "2013-11-13 16:55:44", updated_at: "2013-11-13 16:56:06">
1.9.3p194 :025 > Post.last.update_attribute :hidden_attribute, "ka"
Post Load (0.2ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" DESC LIMIT 1
(0.0ms) begin …Run Code Online (Sandbox Code Playgroud) 我正在使用rails 3我有以下型号
我的控制器
class ContactController < ApplicationController
def index
@surveys = Survey.active
end
end
Run Code Online (Sandbox Code Playgroud)
和我的看法
<%= @surveys.each do |p| %>
<li><%=p.id %>-<%=p.name %></li>
<%end%>
Run Code Online (Sandbox Code Playgroud)
我的预期结果是,每个通过调查变量输出li中的id和name.然而它也会将变量转储到页面底部.
1-name
[#<Survey id: 1, name: "name", is_active: true, user_id: nil, open_script: "Opening Script", voicemail_script: "Voice Mail Script", closing_script: "Closing Script", email_script: "Email Script", created_at: "2012-12-19 15:17:36", updated_at: "2012-12-20 03:46:35">]
Run Code Online (Sandbox Code Playgroud) activerecord ×1
api ×1
facebook ×1
grape-api ×1
mocking ×1
omniauth ×1
performance ×1
rspec ×1
ruby ×1
xml ×1