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.
精彩评论