Hi, this blog is no longer maintained, my new blog is here

Ruby On Rails and a Conning Israeli entrepreneur

List all Controllers and actions

controllers = Dir.new("#{RAILS_ROOT}/app/controllers").entries
controllers.each do |controller|
if controller =~ /_controller/
cont = controller.camelize.gsub(".rb","")
puts cont
(eval("#{cont}.new.methods") -
ApplicationController.methods -
Object.methods -
ApplicationController.new.methods).sort.each {|met|
puts "\t#{met}"
}
end

end

Dump a Model table to fixtures

 


def self.to_fixture
write_file(File.expand_path("test/fixtures/#{table_name}.yml", RAILS_ROOT),
self.find(:all).inject("---\n") { |s, record|
self.columns.inject(s+"#{record.id}:\n") { |s, c|
s+" #{{c.name => record.attributes[c.name]}.to_yaml[5..-1]}\n" }
})
end


The Web Ask eizesus.com

Subscribe

    follow me on Twitter

    Twiters Around

    About Me

    My photo
    I am a web developer for more than 9 years, managed, cried, coded, designed and made money in this industry. now trying to do it again.

    Labels