LoginSignup
6
6

More than 5 years have passed since last update.

モデルの中でurl_helperを使う

Last updated at Posted at 2012-12-26
models/foo.rb
class Foo < ActiveRecord::Base
  include Rails.application.routes.url_helpers
  def base_uri
    foo_path(self)
  end
end
Foo.find(1).base_uri # => /foos/1
6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6