Hi

Models don't belong to controllers. They are two separate classes
that, to make things more practical, often have a similar name.

You could just as easily have a Post model and a BlogController and
Rails wouldn't know the difference.

If you're trying to guess the name of model from the controller that
deals with creating and maintaining its records you could try:

def get_model
  self.class.to_s.gsub("Controller","").singularize.constantize
end

This would return Comment if called in the CommentsController.

Hope that helps?

Gavin

http://handyrailstips.com

On Jul 20, 6:35 am, "Thriving K." <[email protected]>
wrote:
> In controller ,there is something like self. to call the controller
> itsself
>
> if i want to call model that belong to that controller in controller,
> How could i do.
>
> Thank,
> Golf
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to