Roberto Pezzali
Roberto Pezzali

Reputation: 2504

Alias name for a method in Rails not working

Ip'm trying to refactor my gallery model and I have an issue.

I'm using an rss generator that call on my content the methods "summary" and "permalink"

In my gallery.rb the equivalent column of the db are "body" and "slug".

Now I have these two methods:

  def summary
    body
  end

  def permalink
    slug
  end

I'm trying to create an alias in this way:

  alias :summary :body
  alias :permalink :slug

but it doesn't work.

What's the error?

Upvotes: 0

Views: 199

Answers (1)

Marek Lipka
Marek Lipka

Reputation: 51151

You're supposed to use alias_attribute, like this:

alias_attribute :summary, :body
alias_attribute :permalink, :slug

Upvotes: 1

Related Questions