See the method constantize.
On Thu, Feb 9, 2012 at 8:38 PM, Erwin wrote:

I have a polymorphic class Event

class Event < ActiveRecord::Base
belongs_to :taskable, :polymorphic => true

so an event.instance has : event.taskable_type and
event.taskable_id
i.e. event[:taskable_type] = "Project" event[:taskable_id] = 2

Is it possible to localize the taskable_type ( "Project") using
Model.model_name.human ? taskable_type is a string...

I tried to get it from the instance ,
event.taskable.model_name.human, but model_name is not an AR instance
method
( NoMethodError: undefined method `human_name' for #<Project...>


--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 5 | next ›
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedFeb 9, '12 at 10:42p
activeFeb 10, '12 at 6:33a
posts5
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase