I have this in my post model
class Post < ActiveRecord::Base
has_many :tags
has_many :comments
before_validation :generate_permalink
validates :permalink, uniqueness: true
validates :title, presence: true
validates :description, presence: true
def generate_permalink
self.permalink = title.parameterize
end
def to_param
permalink
end
end
and i use this model for both posts controller(admin) and posts controller(blog).
Now due to the nature of this setup, i have problems displaying errors if validations fail on the title (you can read more here: Ruby on Rails won't render edit page without id)
is there a way to easily bypass to_param method for certain controllers and/or actions?
Aucun commentaire:
Enregistrer un commentaire