0

I have a comments scaffold and a movies scaffold.

Users can comment on movie in this path /movies/the-social-network/comments/new

My issue is that the comments use movie_id to work and to link with the movies.

So what I'm asking is how to pass the-social-network as the movie_id?

PS: Im using Friendly Id 4

4

2 に答える 2

0

to_paramを使用できます。たとえば、movie_name「the-social-network」の場合は次のようになります。

class Movie < ActiveRecord::Base
  def to_param
    movie_name
  end
end
于 2013-06-12T06:12:02.183 に答える