firstruby

Master ruby with us

Archive for December, 2009

resource_controller plugin with different associated model

Posted by firstruby on December 17, 2009

If we use resource_controller gem/plugin in Ruby on Rails application, then as per the default configuration, it takes the associated Model name with respective Controller name as,

in app/controllers/posts_controller.rb file,
class PostsController < ResourceController::Base
resource_controller
end

This above configuration will find for Post Model. But if you want to change it to associate it to different model as ‘Comment’ Model, then you can do it as,

class PostsController < ResourceController::Base
resource_controller


private
def model_name
'comment' # Model Name
end
end

Ref. URL – http://jamesgolick.com/resource_controller/rdoc/files/__/README_rdoc.html

Posted in Useful Links | Leave a Comment »