Tag: actioncontroller

如何设置每个环境的config.action_controller.default_url_options = {:host ='#''}

现在我正在使用这个工作的开发主机,但我必须手动更改{:主机=>“”}代码,当我搬到生产。 post.rb def share_all url = Rails.application.routes.url_helpers.post_url(self, :host => 'localhost:3000') if user.authentications.where(:provider => 'twitter').any? user.twitter_share(url) end end 我想使用这个,然后定义每个环境的default_url_options: post.rb def share_all url = Rails.application.routes.url_helpers.post_url(self) if user.authentications.where(:provider => 'twitter').any? user.twitter_share(url) end end 我已经尝试添加到我的config / environments / development.rb但我仍然得到“缺less主机链接到!请提供:主机参数或设置default_url_options [:主机]”错误 development.rb config.action_controller.default_url_options = {:host => "localhost:3000"} 我甚至试过这种方式: development.rb config.action_controller.default_url_options = {:host => "localhost", :port => "3000"} 编辑: 我现在也跟着这个,仍然是相同的错误指南http://edgeguides.rubyonrails.org/action_controller_overview.html#default_url_options […]