Just put this method in model (post.rb).
Model
def to_param
"#{id}-#{name.gsub(/[^a-z0-9]+/i, '-')}"
end
http://www.jroller.com/obie/entry/seo_optimization_of_urls_in
Permalink without ID
Controller
@info = Info.find(params[:id]) # Change the usual find
@info = Info.find_by_nickname(params[:id]) # To look for nickname
Model
def to_param
"#{id}-#{nickname.gsub(/[^a-z0-9]+/i, '-')}" # Change the default
nickname # To display nickname
end
0 comments:
Post a Comment