lapinkoira
lapinkoira

Reputation: 8988

Param variable to string

Which is the best way to convert that :id variable @object = Object.find(params[:id])

into a string?

render :json => {"status" => "404", "message" => "Object with id " + ":id" + " not found"}

Also tried:

render :json => {"status" => "404", "message" => "Object with id #{:id} not found"}

But it gives this error:

no implicit conversion of Symbol into String

Upvotes: 0

Views: 116

Answers (1)

Ilya
Ilya

Reputation: 13487

Just replace #{:id} with "#{params[:id]}"

Upvotes: 3

Related Questions