Is it a class method or an instance method? Meaning do you call it from 
an instance of that model:

@model.some_method

Or do you call it on the model itself:

Model.some_method?


If it's an instance method, you just need to have an instance in the 
controller action:

def index
  @instance = Model.find(params[:id])
  @instance.some_method
end

If you're dealing with a class method you would do this:

def index
  Model.some_method
end

Note: swap out "Model" for the actual name of the model (User, BlogPost, 
etc.)

Hope this helps. Post if you have any other questions.

-- Josh
http://iammrjoshua.com



Cyrus Dev wrote:
> Hello Everyone
> 
> any one know how to call model method in controller ?
> 
> I have one method that is in model and want to call from another
> controller
> 
> please help me
> 
> thanks

-- 
Posted via http://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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to