我发现,如果用户在电子邮件中注册并在我的电子邮件中使用大写字母,那么我会得到零.
例:
username = Dillan@example.com
params[:user][:email] = dillan@example.com
user = User.find_by_email(params[:user][:email])
user.nil?
Run Code Online (Sandbox Code Playgroud)
=>是的
如何在没有区分大小写问题的情况下搜索电子邮件,或者如何编写不区分大小写的find_by_email?
我将数据绘制如下,但我似乎无法显示轴标签:
!function ($) {
var options = {
xaxis: {
mode: "time",
min: start_time,
// max: (new Date()).getTime(),
tickSize: [4, "hour"],
tickLength: 0,
axisLabel: 'Day',
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
axisLabelPadding: 3
},
yaxis: {
axisLabel: 'Amount',
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
axisLabelPadding: 5
},
}
$.plot($("#placeholder"), [open_emails],options);
}(window.jQuery
Run Code Online (Sandbox Code Playgroud)
我在我的视图中包含以下内容并且正在加载它们
//= require jquery.flot
//= require jquery.flot.symbol.min
//= require jquery.flot.axislabels
Run Code Online (Sandbox Code Playgroud)
结果如下:

如何显示标签?
我按照他们网站上的说明包含了simple_captcha gem:
gem 'simple_captcha', :git => 'git://github.com/galetahub/simple-captcha.git'
Run Code Online (Sandbox Code Playgroud)
然后我运行bundler来安装它.
最后,当我运行以下命令时,我收到一个错误:
rails generate simple_captcha
.rvm/gems/ruby-1.9.3-p327@eapi4/bundler/gems/simple-captcha-e99cc7e8bf6b/lib/simple_captcha/form_builder.rb:7:in `included': uninitialized constant Sprockets::Helpers (NameError)
Run Code Online (Sandbox Code Playgroud)
我在网上搜索过,找不到其他任何有这个问题的用户.
任何帮助赞赏
我有以下表单,其中包含一个如图所示的文本区域:
如您所见,蓝色阴影区域和父 div 底部之间有一个空间。
我怎样才能删除这个空间?
html:
<div class="bottomBox">
<h3>Free Quote Form</h3>
<form class="freeQuoteForm" autocomplete="off">
<div class="formFields">
<input type="text" id="firstName" class="input" required><label class="formLabel" for="firstName">First Name</label><input type="text" id="lastName" class="input" required><label class="formLabel" for="LastName">Last Name</label>
</div>
<div class="formFields">
<input type="email" id="email" class="input" required><label class="formLabel" for="email">Email Address</label>
</div>
<div class="formFields">
<textarea rows="12" cols="50" id="sampleText" wrap="hard" class="input" required></textarea><label class="formLabel" for="sampleText">Please include a 1000 word sample from your document.</label>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
css:
.bottomBox {
background: white;
margin: 30px auto;
width: 640px;
height: 700px;
border: 1px solid #9c9c9c; …Run Code Online (Sandbox Code Playgroud) 我正在尝试在Mac OSX 10.5上安装RVM.当我这样做时,我得到以下错误.
mitch:~ mitch$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 185 100 185 0 0 347 0 --:--:-- --:--:-- --:--:-- 0
bash: line 1: html: No such file or directory
bash: line 2: syntax error near unexpected token `<'
'ash: line 2: `<head><title>301 Moved Permanently</title></head>
Run Code Online (Sandbox Code Playgroud)
我也尝试使用这个安装:
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
Run Code Online (Sandbox Code Playgroud)
哪个不会产生任何错误,但也不会安装或下载任何内容.
关于如何安装RVM的任何想法?
先感谢您.
当我使用带有Rspec的水豚时出现以下错误:
/Users/imac/.rvm/gems/ruby-1.9.2-p180@hbg_3.0.7/gems/rack-1.2.3/lib/rack/utils.rb:16: warning: regexp match /.../n against to UTF-8 string
.
Run Code Online (Sandbox Code Playgroud)
在查看github上发布的问题后,他们建议升级到机架1.3.0.
我试图这样做,但这是问题所在:
如果我将机架gem添加到我的gemfile然后进行bundle install我得到:
You have requested:
rack = 1.3.0
The bundle currently has rack locked at 1.2.3.
Try running `bundle update rack`
Run Code Online (Sandbox Code Playgroud)
如果我尝试做捆绑更新机架,我会得到:
Bundler could not find compatible versions for gem "rack":
In Gemfile:
rspec-rails (= 2.6.0) depends on
rack (~> 1.2.1)
rack (1.3.0)
Run Code Online (Sandbox Code Playgroud)
如何更新机架以便我可以摆脱错误消息>
先感谢您.
我的用户表中有数据。一列名为 :provider_user_id,数据类型为 float。
我想将其更改为bigint数据类型。
我应该如何在 Rails 3 中编写此迁移
原始列是通过以下迁移创建的:
class AddFbuidToUsers < ActiveRecord::Migration
def self.up
add_column :users, :provider_user_id, :float
end
def self.down
remove_column :users, :provider_user_id
end
end
Run Code Online (Sandbox Code Playgroud) 我的模型中有以下内容:
company.rb
has_many :merits
accepts_nested_attributes_for :merits
Run Code Online (Sandbox Code Playgroud)
在我的控制器中:
def new
@company = Company.new
@company.merits.build
end
Run Code Online (Sandbox Code Playgroud)
在我的表格上:
= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
= f.simple_fields_for :merits do |m|
= m.input :description, :required => false
= m.input :picture, :required => false
Run Code Online (Sandbox Code Playgroud)
这会产生如下哈希:
..."merits_attributes"=>{"0"=>{"description"=>"stove", "picture"=>"www.it.com/stove.png"}}...
我想要的是多个对象如下:
..."merits_attributes"=> {"0"=> {"description"=>"炉灶","图片"=>"www.it.com/stove.png"},"1"=> {"cription "=>"冰箱","图片"=>"www.it.com/fridge.png"}} ...
我可以这样做,我该怎么做呢?如果在控制器中它会创建多个对象使用:
def create
@company = Company.new(params[:company])
if @company.save
sign_in @company
redirect_to root_path
else
render :new
end
Run Code Online (Sandbox Code Playgroud) 我正在为我的应用程序创建测试。
创建 quote_request 后,我会向用户发送一封确认电子邮件。我还发了一封电子邮件通知校对人员。
我仍在学习 Ruby,我确信有更好的方法来编写以下代码:
def email_exists?(email_address)
ActionMailer::Base.deliveries.each do |m|
if m[:to].to_s == email_address
return true
end
end
end
def email_with_subject_exists?(email_address, email_subject)
ActionMailer::Base.deliveries.each do |m|
if m[:to].to_s == email_address && m[:subject].to_s == email_subject
return true
else
return false
end
end
end
Run Code Online (Sandbox Code Playgroud)
我发现,如果我不包含 return false,那么由于某种原因,电子邮件的全部内容都会输出。
任何改进此代码的帮助将不胜感激。
以下是 ActionMailer::Base.deliveries 的内容:
[#<Mail::Message:70094817191440, Multipart: true, Headers: <Date: Thu, 01 Sep 2016 15:50:35 +0700>, <From: from@example.com>, <To: peterjohnson1@example.com>, <Message-ID: <57c7ebdb1b5f4_2ab93fc03545e1f850559@Mitchell-Goulds-MacBook-Air.local.mail>>, <Subject: Welcome to the ProvenWord team!>, <Mime-Version: 1.0>, <Content-Type: multipart/alternative; boundary="--==_mimepart_57c7ebdb16e49_2ab93fc03545e1f85046d"; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>>, …Run Code Online (Sandbox Code Playgroud) Rails 5.2 我有以下 ApplicationCable::Connection ruby 文件:
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = find_verified_user
end
private
def find_verified_user
if verified_user = env['warden'].user
verified_user
else
message = "The user is not found. Connection rejected."
logger.add_tags 'ActionCable', message
self.transmit error: message
reject_unauthorized_connection
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
我想测试此设置并使用以下 RSpec 测试:
require 'rails_helper.rb'
RSpec.describe ApplicationCable::Connection, type: :channel do
it "successfully connects" do
connect "/cable", headers: { "X-USER-ID" => 325 }
expect(connection.user_id).to eq 325
end
end
Run Code Online (Sandbox Code Playgroud)
失败的原因是:
失败/错误:如果verified_user = env['warden'].user …
rspec ×2
actioncable ×1
captcha ×1
capybara ×1
css ×1
devise ×1
flot ×1
html ×1
migration ×1
nested-forms ×1
rspec-rails ×1
ruby ×1
rvm ×1
simple-form ×1