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

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -