我不知道如何在Ubuntu上安装最新的Ruby.
首先,我使用了默认的Ruby 1.9.3
sudo apt-get install ruby
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用安装2.0版本
sudo apt-get install ruby2.0
Run Code Online (Sandbox Code Playgroud)
我的Ruby版本仍然是"ruby 1.9.3p484(2013-11-22修订版43786)[x86_64-linux])"
我该怎么办?
我不知道如何(或在何处)从AWS授予用户读写权限,以便用户可以在生产环境中的sample_app上发布图片.这是第11章的最后一项任务,它没有被教程所涵盖,我无法在任何地方找到解决方案.
这是carrier_wave.rb文件:
if Rails.env.production?
CarrierWave.configure do |config|
config.fog_credentials = {
# Configuration for Amazon S3
:provider => 'AWS',
:aws_access_key_id => ENV['lalala'],
:aws_secret_access_key => ENV['oloalle']
}
config.fog_directory = ENV['name of bucket']
end
end
Run Code Online (Sandbox Code Playgroud)
这是教程中的过程:1)创建AWS IAM用户并记录访问权限和密钥 - 完成
2)创建S3桶 - 完成
3)授予对上一步创建的用户的读写权限 - 如何???
4)然后我运行这三个命令:
$ heroku config:set S3_ACCESS_KEY=lalala
$ heroku config:set S3_SECRET_KEY=oloalle
$ heroku config:set S3_BUCKET=name of bucket
Run Code Online (Sandbox Code Playgroud)
5)推送到git和heroku - 完成
6)heroku pg:reset DATABASE- 完成
7)heroku run rake db:migrate在这里我得到这样的信息:
Running `rake db:migrate` attached to …Run Code Online (Sandbox Code Playgroud) ruby-on-rails amazon-web-services railstutorial.org amazon-iam
如何在不需要模型属性存在的情况下进行验证,但如果存在,属性的长度必须超过三个字符?
activerecord ruby-on-rails ruby-on-rails-4 rails-activerecord ruby-on-rails-4.2
我正在尝试测试Hartl的sample_app,这是我在运行后获得的消息bundle exec rake test:
DEPRECATION WARNING: The configuration option `config.serve_static_assets` has been renamed to `config.serve_static_files` to clarify its role (it merely enables serving everything in the `public` folder and is unrelated to the asset pipeline). The `serve_static_assets` alias will be removed in Rails 5.0. Please migrate your configuration files accordingly. (called from block in <top (required)> at /home/aki/sample_app/config/environments/test.rb:16)
rake aborted!
test_should_be_valid is already defined in UserTest
/home/aki/.rvm/gems/ruby-2.1.3/gems/activesupport-4.2.0/lib/active_support/testing/declarative.rb:14:in `test'
/home/aki/sample_app/test/models/user_test.rb:10:in `<class:UserTest>'
/home/aki/sample_app/test/models/user_test.rb:3:in `<top (required)>'
/home/aki/.rvm/gems/ruby-2.1.3/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
/home/aki/.rvm/gems/ruby-2.1.3/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in …Run Code Online (Sandbox Code Playgroud)