HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/gems/default/doc/activerecord-6.1.4.1/ri/ActiveRecord/Integration/to_param-i.ri
U:RDoc::AnyMethod[iI"
to_param:ETI"'ActiveRecord::Integration#to_param;TF:publico:RDoc::Markup::Document:@parts[
o:RDoc::Markup::Paragraph;	[I"OReturns a +String+, which Action Pack uses for constructing a URL to this ;TI"Pobject. The default implementation returns this record's id as a +String+, ;TI"'or +nil+ if this record's unsaved.;To:RDoc::Markup::BlankLineo;
;	[I"JFor example, suppose that you have a User model, and that you have a ;TI"A<tt>resources :users</tt> route. Normally, +user_path+ will ;TI"8construct a path with the user object's 'id' in it:;T@o:RDoc::Markup::Verbatim;	[I"*user = User.find_by(name: 'Phusion')
;TI"&user_path(user)  # => "/users/1"
;T:@format0o;
;	[I"MYou can override +to_param+ in your model to make +user_path+ construct ;TI";a path using the user's name instead of the user's id:;T@o;;	[
I"%class User < ActiveRecord::Base
;TI""  def to_param  # overridden
;TI"    name
;TI"  end
;TI"	end
;TI"
;TI"*user = User.find_by(name: 'Phusion')
;TI"+user_path(user)  # => "/users/Phusion";T;
0:
@fileI"%lib/active_record/integration.rb;T:0@omit_headings_from_table_of_contents_below000[I"();T@(FI"Integration;TcRDoc::NormalModule00