我有以下数组
cities = ["Kathmandu", "Pokhara", "", "Dharan", "Butwal"]
Run Code Online (Sandbox Code Playgroud)
我想从数组中删除空白元素,并希望得到以下结果:
cities = ["Kathmandu", "Pokhara", "Dharan", "Butwal"]
Run Code Online (Sandbox Code Playgroud)
有没有像compact这样的方法没有循环?
我使用gem 1.3.7,rails 2.3.5和ruby 1.8.7(2008-08-11 patchlevel 72).启动服务器时,我得到低于警告.
Loading development environment (Rails 2.3.5)
/Users/me/.rvm/gems/ruby-1.8.7-p72@mbm/gems/rmagick-2.13.1/lib/RMagick.rb:44: warning: already initialized constant PercentGeometry
/Users/me/.rvm/gems/ruby-1.8.7-p72@mbm/gems/rmagick-2.13.1/lib/RMagick.rb:45: warning: already initialized constant AspectGeometry
/Users/me/.rvm/gems/ruby-1.8.7-p72@mbm/gems/rmagick-2.13.1/lib/RMagick.rb:46: warning: already initialized constant LessGeometry
/Users/me/.rvm/gems/ruby-1.8.7-p72@mbm/gems/rmagick-2.13.1/lib/RMagick.rb:47: warning: already initialized constant GreaterGeometry
/Users/me/.rvm/gems/ruby-1.8.7-p72@mbm/gems/rmagick-2.13.1/lib/RMagick.rb:48: warning: already initialized constant AreaGeometry
/Users/me/.rvm/gems/ruby-1.8.7-p72@mbm/gems/rmagick-2.13.1/lib/RMagick.rb:49: warning: already initialized constant MinimumGeometry
/Users/me/.rvm/gems/ruby-1.8.7-p72@mbm/gems/rmagick-2.13.1/lib/RMagick.rb:52: warning: already initialized constant FLAGS
/Users/me/.rvm/gems/ruby-1.8.7-p72@mbm/gems/rmagick-2.13.1/lib/RMagick.rb:58: warning: already initialized constant RFLAGS
/Users/me/.rvm/gems/ruby-1.8.7-p72@mbm/gems/rmagick-2.13.1/lib/RMagick.rb:92: warning: already initialized constant W
/Users/me/.rvm/gems/ruby-1.8.7-p72@mbm/gems/rmagick-2.13.1/lib/RMagick.rb:93: warning: already initialized constant H
/Users/me/.rvm/gems/ruby-1.8.7-p72@mbm/gems/rmagick-2.13.1/lib/RMagick.rb:94: warning: already initialized constant X
/Users/me/.rvm/gems/ruby-1.8.7-p72@mbm/gems/rmagick-2.13.1/lib/RMagick.rb:95: warning: already …Run Code Online (Sandbox Code Playgroud) 我有一个阵列tempArray = ["Kathmandu","Pokhara","Dharan"].为了确保"博卡拉"在tempArry中,我必须使用循环并检查tempArray的每个元素.
有没有办法实现Ruby,Array.include?所以我不需要使用循环?
我无法ar_sendmail从终端运行命令.我不认为我错过了它的配置.以下是我的代码;
development.rb
++++++++++++++++++++++++++++++++++++++++++++++++++++
ActionMailer::Base.delivery_method = :activerecord
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 25,
:domain => "www.google.com",
:authentication => :plain,
:user_name => "ashis.lun@gmail.com",
:password => "kathmandu",
:enable_starttls_auto => true
}
require "action_mailer/ar_mailer"
Gemfile +++++++++++++++++++++++++++ gem "ar_mailer", "1.5.1"
My Mailer
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class Postoffice < ActionMailer::ARMailer
def recover_password_email(account, name, address)
@recipients = address
@from = "ashis.lun@gmail.com"
@subject = "Your Account at #{account.org_name} is Ready"
@body["subdomain"] = account.subdomain
@body["name"] = name
@body["org_name"] = account.org_name
@body["password"] = password
@body["email"] = address … 我以前无法运行./script/console,因为我的script console文件已经包含,它曾经抛出错误#!/usr/bin/env ruby19.做命中和试用后,我通过更换固定这个错误#!/usr/bin/env ruby19有#!/usr/bin/env ruby.
以上几行有什么作用?
版本:
我得到以下链接来解决与类和实例方法相关的问题. http://www.fakingfantastic.com/2010/09/20/concerning-yourself-with-active-support-concern/
module NotificationsHelper
extend ActiveSupport::Concern
module ClassMethods
def my_class_method
# ...
end
end
module InstanceMethods
def my_instance_method
# ...
end
end
end
但我得到了未初始化的常量ActiveSupport :: Concern错误.我正在使用Rails 2.3.5和Ruby 1.9.2p180
我正在使用rails 2.3.5,我希望我们Rspec进行测试.我已经安装了rspec gem但是无法在生成器列表中列出rspec.我指的是https://github.com/rspec/rspec-rails.
group :development, :test do gem "rspec", "~> 1.3" gem "rspec-rails", "~> 1.3" end
谢谢.
rspec ruby-on-rails ruby-on-rails-plugins rspec-rails ruby-on-rails-2
ruby ×3
actionmailer ×1
activerecord ×1
ar-mailer ×1
arrays ×1
git ×1
github ×1
helpers ×1
javascript ×1
rmagick ×1
rspec ×1
rspec-rails ×1
rubygems ×1
sendmail ×1