我在其中一个观点中称之为偏:
<%= render :partial => 'events/attendees', :collection => @attendees %>
Run Code Online (Sandbox Code Playgroud)
但是部分由于某种原因运行了两次...这里是部分:
<% @attendees.each do |user| %>
<li><%= link_to user.name, user %></li>
<% end %>
Run Code Online (Sandbox Code Playgroud)
并且我验证了rails实际上运行了这个部分两次因为输出显示来自@attendees的每个项目两次
我最近克隆了一个github repo,我试图让它在我的mac上工作.我克隆了它,做了捆绑安装并安装了所有的宝石.当我尝试做"rails server"时,我收到一个错误:
=> Booting Mongrel
=> Rails 3.0.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/local/rvm/gems/ruby-1.8.7-p302@rails301/gems/railties-3.0.1/lib/rails/application/configuration.rb:86:in `read': No such file or directory - /Users/beatjunkie84/Desktop/Teamly/config/database.yml (Errno::ENOENT)
from /usr/local/rvm/gems/ruby-1.8.7-p302@rails301/gems/railties-3.0.1/lib/rails/application/configuration.rb:86:in `database_configuration'
from /usr/local/rvm/gems/ruby-1.8.7-p302@rails301/gems/activerecord-3.0.1/lib/active_record/railtie.rb:58
from /usr/local/rvm/gems/ruby-1.8.7-p302@rails301/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /usr/local/rvm/gems/ruby-1.8.7-p302@rails301/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /usr/local/rvm/gems/ruby-1.8.7-p302@rails301/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:26:in `on_load'
from /usr/local/rvm/gems/ruby-1.8.7-p302@rails301/gems/activerecord-3.0.1/lib/active_record/railtie.rb:57
from /usr/local/rvm/gems/ruby-1.8.7-p302@rails301/gems/railties-3.0.1/lib/rails/initializable.rb:25:in `instance_exec'
from /usr/local/rvm/gems/ruby-1.8.7-p302@rails301/gems/railties-3.0.1/lib/rails/initializable.rb:25:in `run'
from /usr/local/rvm/gems/ruby-1.8.7-p302@rails301/gems/railties-3.0.1/lib/rails/initializable.rb:50:in `run_initializers'
from /usr/local/rvm/gems/ruby-1.8.7-p302@rails301/gems/railties-3.0.1/lib/rails/initializable.rb:49:in `each'
from /usr/local/rvm/gems/ruby-1.8.7-p302@rails301/gems/railties-3.0.1/lib/rails/initializable.rb:49:in `run_initializers'
from /usr/local/rvm/gems/ruby-1.8.7-p302@rails301/gems/railties-3.0.1/lib/rails/application.rb:134:in `initialize!'
from /usr/local/rvm/gems/ruby-1.8.7-p302@rails301/gems/railties-3.0.1/lib/rails/application.rb:77:in `send'
from /usr/local/rvm/gems/ruby-1.8.7-p302@rails301/gems/railties-3.0.1/lib/rails/application.rb:77:in `method_missing'
from /Users/beatjunkie84/Desktop/Teamly/config/environment.rb:5
from …Run Code Online (Sandbox Code Playgroud) 这是GA输出代码:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA_CODE']);
_gaq.push(['_setDomainName', 'SUBDOMAIN']);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackEvent', 'Priority', 'Created (day)', 'Label info', '']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
Run Code Online (Sandbox Code Playgroud)
trackEvent行似乎是正确的......但由于某种原因没有跟踪.是因为我离开了值字段为零吗?
我有一个rails应用程序,当用户填写表单时,用新的信用卡ping条纹.然后它完成后重定向回主页.但是,条纹说我正在返回503(我认为这是代码)而不是200.我正在做一个常规的redirect_to:root.如何确保还返回200代码?
我的团队和我正在使用twilio发送短信.一切似乎在其他人的本地机器上运行正常(具有相同的确切代码),除了twilio总是向我返回一个验证错误.我正在将消息发送到他们的"特殊号码",因此它实际上不会发送真正的短信,但它仍会返回验证错误.
这是我们发送消息的一些代码:
def send_sms
self.from_phone_number = CONFIG['live_twilio'] ? self.customer.assigned_phone_number : CONFIG['test_phone_number']
self.to_phone_number = CONFIG['live_twilio'] ? self.customer.customer_phone_number : CONFIG['test_phone_number']
begin
report_to_new_relic_insights
send_message_with_twilio!
rescue Twilio::REST::RequestError => e
self.error_description = e.message
end
self.dispatched_at = Time.now
self.save(validate: false)
return e
end
def send_message_with_twilio!
unless self.customer.example_customer?
twilio_params = {
from: "+1#{from_phone_number}",
to: "+1#{to_phone_number}",
body: self.text
}
if ENV['RECORD_TWILIO_STATUSES'].in?(['1', 'true'])
twilio_params[:status_callback] = "#{CONFIG['secure_domain']}/messages/#{id}/update_status"
end
client.account.messages.create(twilio_params)
else
# @onboarding_flow
# don't send the actual SMS to the example customer
self.customer.send_reply_as_example_customer! if self.customer.first_reply?
end
end
def …Run Code Online (Sandbox Code Playgroud) 我安装了Ruby 1.9.2.我用过rvm use 1.9.2,然后当我打字ruby -v时说1.9.2.然后,当我退出终端并重新打开它时,它再次显示1.8.7.
我究竟做错了什么?
首先,在我的application.rb文件和我的environment.rb文件中配置有什么区别?
我读到我需要在environment.rb文件中配置我的timezone默认值.我不太清楚如何做到这一点.到目前为止,我在我的environment.rb文件中有这个:
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
SampleApp::Application.initialize!
Run Code Online (Sandbox Code Playgroud)
进行更改后是否需要重新运行rails服务器?还有其他步骤吗?
谢谢!
我正在尝试为我的模型用户创建一个rspec,但每次运行时:
rails g rspec_model User
Run Code Online (Sandbox Code Playgroud)
我得到找不到生成器rspec_model.
我检查了另一个stackoverflow线程,它说确保我有宝石'rspec-rails',我这样做.我究竟做错了什么?这是我的gemfile:
group :test do
# Pretty printed test output
gem 'turn', :require => false
gem 'rspec', '2.0.1'
gem 'webrat', '0.7.1'
end
group :development do
gem 'rspec-rails', '2.0.1'
gem 'sqlite3'
end
Run Code Online (Sandbox Code Playgroud) 我知道这是一个非常简单的问题,但我无法确定在初始安装时主动管理员为您提供的登录/传递更改位置.
我现在正在阅读一些铁轨书籍,似乎无法理解何时使用一种测试而不是另一种.是否有一些简单的规则可以了解何时使用集成测试?
我试图允许自己使用主动管理员为每个模型上传5个图像,但我似乎无法弄清楚如何做到这一点.到目前为止,这是我的activeadmin代码:
ActiveAdmin.register Piece do
form :html => { :enctype => "multipart/form-data" } do |f|
f.inputs "Details" do
f.input :name
f.input :description
f.input :cost
f.input :category
f.input :photo, :as => :file, :hint => f.template.image_tag(f.object.photo.url(:medium))
end
f.buttons
end
index do
column :id
column :name
column :cost
column :category
column :inventory_count
column :available_count
column :materials
column :created_at
default_actions
end
end
Run Code Online (Sandbox Code Playgroud)
我如何一次允许5而不是1?
我建立了一个项目,并一直把它推到git hub.然后我制作了一个文件夹的副本(在我的本地机器上)并开始向它走另一个方向.我在github上创建了一个新的repo,但它不会让我推动更改,因为它仍然认为它是旧回购的一部分.当我更改名称时,它会将本地计算机上的文件重置为上一个回购!在尝试这个之前我保存了一份副本.
基本上我想要做的是在我的当前项目上使用github启动一个新的repo,但保留我过去做的所有git修订.这可能吗?
我已经多次做过这种类型的陈述,但它现在告诉我这个陈述含糊不清.这是错误:
Mysql::Error: Column 'created_at' in where clause is ambiguous: SELECT COUNT(DISTINCT `tasks`.`id`) AS count_id FROM `tasks` LEFT OUTER JOIN `users` ON `users`.`id` = `tasks`.`author_id` WHERE (created_at >= '2012-01-14 18:38:29')
Run Code Online (Sandbox Code Playgroud)
这是声明:
Task.count(:conditions => ["created_at > ?", 1.month.ago])
Run Code Online (Sandbox Code Playgroud)
我在这做错了什么?
ruby-on-rails ×12
activeadmin ×2
rspec ×2
activerecord ×1
github ×1
ruby ×1
rvm ×1
timezone ×1
twilio ×1