List all Models, Controllers, Views and Tests

63 views
Skip to first unread message

Gurdipe Dosanjh

unread,
Apr 6, 2012, 7:13:43 PM4/6/12
to rubyonra...@googlegroups.com

Hi All,


List all Models, Controllers, Views and Tests


I am writing a plug in and I need to list all the models and their related controllers, views and any unit test scripts for models, functional test scripts for controllers and integration test scripts for views.

How would I be able to get this information and display it using Rails?

Kind Regards

Gurdipe

Rogerio Medeiros

unread,
Apr 6, 2012, 9:38:48 PM4/6/12
to rubyonra...@googlegroups.com
Hello

in ur app, get models

 Dir['app/models/*.rb'].map {|f| File.basename(f, '.*').camelize.constantize }
  def get_model_names_sub
      Module.constants.select do |constant_name|
              constant = eval constant_name
              if not constant.nil? and constant.is_a? Class and constant.superclass == ActiveRecord::Base
                  constant
              end
      end
  end

2012/4/6 Gurdipe Dosanjh <rhomob...@gmail.com>

Gurdipe

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/pKL5k9z3e3cJ.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.



--
att,

Rogerio

A complicação se descomplica na mesma proporção que fazemos os nós se desatarem ao tecer o conhecimento do saber.

Gurdipe Dosanjh

unread,
Apr 7, 2012, 4:09:34 AM4/7/12
to rubyonra...@googlegroups.com

Hi Rogerio,


Thanks for the awesome brilliant reply, it’s been a great help to me.


Gurdipe

Reply all
Reply to author
Forward
0 new messages