I want to convert the title of a page to a friendly URL and store it in the database as a permalink. My problem is I can't use the parameterize
method. It's not working. Other inflections are working like upcase
or downcase
but parameterize
is not working. Is there a special case for parameterize
?
This is my code:
Controller:
def create
params[:page][:permalink] = params[:page][:title].dup
@page = Page.new(params[:page])
end
Model:
class Page < ActiveRecord::Base
before_save :makeitpermalink
before_update :makeitpermalink
private
def makeitpermalink
permalink.parameterize!
end
end