Module: AppyantraAdmin::Utils
- Included in:
- ProfilesController, UsersController
- Defined in:
- lib/appyantra_admin/utils.rb
Instance Method Summary collapse
-
#list_page_layouts(layouts = []) ⇒ Object
returns the list of available page layouts.
-
#random_password(size = 10) ⇒ Object
generates a random password.
Instance Method Details
#list_page_layouts(layouts = []) ⇒ Object
returns the list of available page layouts
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/appyantra_admin/utils.rb', line 10 def list_page_layouts(layouts=[]) if layouts.empty? layouts_path = Rails.root + "app/views/layouts" if Dir.exists? layouts_path Dir.foreach(layouts_path) do |file_name| if file_name.include? '.html.haml' layouts << File.basename(file_name,'.html.haml') elsif file_name.include? '.html.erb' layouts << File.basename(file_name,'.html.erb') end end end layouts << 'application' if layouts.empty? end layouts end |
#random_password(size = 10) ⇒ Object
generates a random password
4 5 6 7 |
# File 'lib/appyantra_admin/utils.rb', line 4 def random_password(size=10) chars = (('a'..'z').to_a + ('0'..'9').to_a) - %w(i o 0 1 l 0) (1..size).collect{|a| chars[rand(chars.size)] }.join end |