ruby - rails model file path -
how can obtain model file path in rails? want that:
mymodel.file_path
expected result: "/app/models/my_model.rb
it's possible in rails or need create file name models name , find in models directory?
i think have build it, simple.
here goes:
def model_path model_file = self.class.name.split("::").map {|c| c.downcase }.join('/') + '.rb' path = rails.root.join('app/models/').join(model_file) end
Comments
Post a Comment