开发者

How to init slug mongoid_slug for generated model in Rails 3?

开发者 https://www.devze.com 2023-04-10 12:02 出处:网络
I have a project and everything is near complete! I\'ve just used mongoid_slug for my project to make readable link! In my model, i have 2 more lines: \"include Mongoid:slug\" and \"slug :title\" and

I have a project and everything is near complete! I've just used mongoid_slug for my project to make readable link! In my model, i have 2 more lines: "include Mongoid:slug" and "slug :title" and in my controller I call *.find_by_slug(params[:id]) but the result is always is null! After finding for a while, I find out that my old models does't load the slug!! I know that I have to init my slug for my model first, and I have to write a rake tastk in db.rb! However, I dont' know how to write开发者_JAVA技巧 it!! Is there any suggestion? Thanks you!


Are you using inherited resources? if so yo will need to override the definitions of collection and resource to use find by slug.

0

精彩评论

暂无评论...
验证码 换一张
取 消