当我尝试捆绑安装时,我收到以下消息:
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.0
Run Code Online (Sandbox Code Playgroud)
在我的Gemfile中,我有以下内容:
ruby '2.1.0'
Run Code Online (Sandbox Code Playgroud)
当我ruby -v在控制台中运行时,我得到:
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0]
Run Code Online (Sandbox Code Playgroud)
Ruby 2.1.0p0是什么意思?我的Gemfile应该有什么版本,为什么错误告诉我我有Ruby版本2.0.0?
我试图回答Chris Pine的"学习编程"一书中的以下问题:
闰年.编写一个程序,要求开始年份和结束年份,然后将所有闰年放在它们之间(如果它们也是闰年,则包括它们).闰年是可被4整除的年份(如1984年和2004年).然而,被100整除的年份不是闰年(例如1800和1900),除非它们也可被400整除(例如1600和2000,实际上是闰年).真是一团糟!
运行代码时出现以下错误:
leap_year.rb:12:in +': no implicit conversion of Fixnum into String (TypeError)
from leap_year.rb:12:in'
这是我的代码:
#leap years
puts 'What is the starting year?'
starting_year = gets.chomp
puts 'What is the ending year?'
ending_year = gets.chomp
while starting_year <= ending_year
if starting_year%4 == 0 && (starting_year%100 != 0 && starting_year%400 == 0)
puts starting_year
end
starting_year+=1
end
Run Code Online (Sandbox Code Playgroud) 我一直收到以下错误消息:
text.rb:2:in `<main>': undefined method `choices' for main:Object (NoMethodError)
Run Code Online (Sandbox Code Playgroud)
但我似乎无法理解为什么我的方法是"未定义的":
puts "Select [1] [2] [3] or [q] to quit"; users_choice = gets.chomp
choices(users_choice)
def choices (choice)
while choice != 'q'
case choice
when '1'
puts "you chose one!"
when '2'
puts "you chose two!"
when '3'
puts "you chose three!"
end
end
end
Run Code Online (Sandbox Code Playgroud) 我不明白为什么我要提出这个致命的例外.它工作得很好localhost.
我知道这SIGTERM只是一个终止程序的信号,我不相信解决方案是处理或忽略它.
当我查看部署的网站时,它显示为白页.如何修复此错误以便我的应用程序可以正常显示?
这是我的Heroku日志:
2014-04-23T20:59:57.995734+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `block in start'
2014-04-23T20:59:57.995789+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:32:in `start'
2014-04-23T20:59:57.995875+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in `start'
2014-04-23T20:59:57.995933+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:14:in `run'
2014-04-23T20:59:57.995988+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:264:in `start'
2014-04-23T20:59:57.996042+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/commands/server.rb:84:in `start'
2014-04-23T20:59:57.996552+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/commands.rb:71:in `<top (required)>'
2014-04-23T20:59:57.996843+00:00 app[web.1]: [2014-04-23 20:59:57] INFO WEBrick::HTTPServer#start done.
2014-04-23T20:59:57.996932+00:00 app[web.1]: Exiting
2014-04-23T20:59:57.996466+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/commands.rb:71:in `tap'
2014-04-23T20:59:57.996333+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/commands.rb:76:in `block in <top (required)>'
2014-04-23T20:59:57.996777+00:00 app[web.1]: [2014-04-23 20:59:57] INFO going to shutdown ...
2014-04-23T20:59:57.996607+00:00 app[web.1]: bin/rails:4:in `require'
2014-04-23T20:59:57.996688+00:00 app[web.1]: bin/rails:4:in `<main>'
2014-04-23T20:59:59.247265+00:00 …Run Code Online (Sandbox Code Playgroud) 这是我第一次安排任务,我不确定最佳实施(或正确的实施).
我的目标: 我在rails 4应用程序设置上使用twilio并部署在Heroku上.我希望应用程序每周一次使用自定义文本消息(由数据库中的信息编写和创建)自动为所有用户发送文本.
从研究中我得到了以下宝石:每当和Rufus-Scheduler.
我相信这两个宝石都可以完成工作,但在阅读Rufus的文档时:"请注意:rufus-scheduler不是cron替代品"我试图理解我想要的是否确实是一个cron工作或一个"Rufus-Scheduler".
我留下了以下问题:什么是cron作业以及何时适合使用它?为什么Rufus-Scheduler不是cron替代品,它有什么不同的做法?我应该使用哪一个?
我使用ActiveAdmin创建了一个自定义页面,如下所示:
ActiveAdmin.register_page "message_list" do
controller do
def index
@collection = client().account.messages.list.sort_by{ |message| Date.rfc2822(message.date_sent) }.reverse
render :layout => 'active_admin'
end
end
end
Run Code Online (Sandbox Code Playgroud)
我创建了一个index.html.erb文件,其中包含我要在此页面上显示的表.然而,这不是最佳的.如何使用也带有分页的活动管理标准表格布局并将其与我的表格信息一起显示?我知道ActiveAdmin PageDSL Class不包含#index,因此我不能简单地做到:
index do
selectable_column
id_column
column :to
column :from
default_actions
end
Run Code Online (Sandbox Code Playgroud)
除了在自定义页面上实现ActiveAdmin的表格布局外,如何更改页面本身的标题?截至目前,它被称为"索引".
我想把我的锚标记放在它的div中.
这是html文件:
<div class="body_div">
<div class="verticle_center">
<div id="links">
...
<div id="linkedin" class="fill">
<a href="#">linkedin</a>
</div>
...
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是css.scss:
.body_div {
display: table;
height: 100%;
overflow: hidden;
margin: 0 auto;
.verticle_center{
display: table-cell;
vertical-align: middle;
padding: 0 5px;
}
#linkedin {
text-align: center;
color: rgba(26, 132, 188, 1);
box-shadow: inset 0 -2px 0 rgba(26, 132, 188, 1);
display: inline;
margin: 10px 7px;
padding: 5px 5px;
font-weight: 700;
font-size: 15px;
letter-spacing: 2px;
text-transform: uppercase;
background: none;
z-index: 1;
cursor: pointer; …Run Code Online (Sandbox Code Playgroud) 我正在创建一个带有涟漪效果的谷歌材质设计按钮,但当我希望它成为圆形时,我的动画显示为方形.
发生这种情况是因为动画的大小大于它所在的div,然后填充外部div的边缘,使其看起来像一个正方形.有没有办法将外部div本身设置为圆形,因为即使我已经设置border-radius: 50%,div本身(不是在div中创建的形状)仍然是正方形.
HTML:
<div id="imgs">
<div id="button"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
#button{
position: relative;
overflow: hidden;
height: 56px;
width: 56px;
border-radius: 50%;
-webkit-box-shadow: 0px 1px 5px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 0px 1px 5px 0px rgba(50, 50, 50, 0.75);
box-shadow: 0px 1px 5px 0px rgba(50, 50, 50, 0.75);
}
.drop{
display: block;
position: absolute;
background: hsl(180, 40%, 80%);
border-radius: 50%;
transform: scale(0);
}
.drop.animate {
-webkit-animation-name: ripple;
-webkit-animation-duration: 0.65s;
-webkit-animation-timing-function: linear;
}
@-webkit-keyframes ripple {
100% {opacity: 0; …Run Code Online (Sandbox Code Playgroud) ruby ×3
css ×2
activeadmin ×1
anchor ×1
centering ×1
cron ×1
deployment ×1
fixnum ×1
gemfile ×1
heroku ×1
html ×1
javascript ×1
sigterm ×1
text-align ×1
whenever ×1