我正在尝试在本地主机上运行我们公司的产品源代码。我试过放置
config.action_mailer.default_url_options = { host: "localhost:3000" }
在所有 Development.rb、test.rb 和 production.rb 中。但是当我跑步时
rake db:seed
我仍然不断得到
ActionView::Template::Error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true.
我正在按照编辑中的建议添加我的配置/数据库.yml 文件config/database.yml
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password: ******
socket: /var/run/mysqld/mysqld.sock
development:
<<: *default
database: company_development
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: coompany_test
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
production:
<<: *default
database: company_production
username: company
password: <%= ****** %>
任何帮助将不胜感激。谢谢。
我猜您正在尝试用种子填充开发环境,如果是这种情况,请尝试此操作
rake db:seed RAILS_ENV=development
我明白了。对不起,我忘了回答。对于每个人的此特定错误,解决方案可能会有所不同。但对我来说,我必须在以下文件中进行以下更改。
在应用程序.yml中,我添加了
SMTP_HOST: 'localhost:3000'
在开发中,我添加了
config.action_mailer.raise_delivery_errors = false
播种完成。