Last active
December 13, 2015 19:59
-
-
Save lxyuma/4967124 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# railsのmodelで***_path(resourceのURL)を使う方法 | |
- Rails.application.routes.url_helpers.posts_path | |
- 参考 | |
- http://stackoverflow.com/questions/5380703/rails-get-resource-path-in-model | |
- ところが、これだと、パスしか分からない。URLのホスト部分が入らない。 | |
- posts_urlに変えると、以下のエラーが出る。 | |
- ArgumentError (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true): | |
- config/environments/***.rb | |
- Rails.application.routes.default_url_options[:host] = 'localhost:3000' | |
- 参考 | |
- http://d.hatena.ne.jp/InvokeTwoA/20111121 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment