What is the meaning of the method to_param?

Hey!

Foe example i have next code:

test “should update user” do
put :update, id: @user.to_param, user: @input_attributes
assert_redirected_to users_path
end

What return id: @user.to_param?

to_param return the representaion of the object in the context of url
params.
ActiveRecord objects (like your @user) respond to to_param with their
id.

That means, @user.to_param == @user.id

You can override this by defining the method in your ActiveRecord class
(this is just a example, dont do this way):

def to_param
self.name
end

2013/4/12 Dmitrij B. [email protected]

Ricardo Franco Andrade

( Web | Desktop | Game ) Developer

email: [email protected]
phone: +55 (86) 9436 0830
linkedin: http://www.linkedin.com/pub/ricardo-franco/61/2b0/857
skype: ricardo.krieg
github: ricardokrieg (Ricardo Andrade) · GitHub
twitter: twitter.com/ricardokrieg
facebooK: Redirecting...