Module: RailsDb::ApplicationHelper
- Defined in:
- app/helpers/rails_db/application_helper.rb
Instance Method Summary collapse
- #db_hint_options ⇒ Object
- #fa_icon(icon_name) ⇒ Object
- #link_to_add_fields(name, f, type) ⇒ Object
- #main_content_classes ⇒ Object
- #params_to_hash(p) ⇒ Object
- #rails_db_tables ⇒ Object
- #show_sidebar? ⇒ Boolean
- #sidebar_classes ⇒ Object
- #title(str) ⇒ Object
Instance Method Details
#db_hint_options ⇒ Object
47 48 49 50 51 52 53 |
# File 'app/helpers/rails_db/application_helper.rb', line 47 def result = {} RailsDb::Database.accessible_tables.each do |table_name| result[table_name] = RailsDb::Table.new(table_name).columns.inject({}) {|res, e| res[e.name] = nil; res } end result end |
#fa_icon(icon_name) ⇒ Object
43 44 45 |
# File 'app/helpers/rails_db/application_helper.rb', line 43 def fa_icon(icon_name) %{<i class="fa fa-#{icon_name}"></i>}.html_safe end |
#link_to_add_fields(name, f, type) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'app/helpers/rails_db/application_helper.rb', line 7 def link_to_add_fields(name, f, type) new_object = f.object.send "build_#{type}" id = "new_#{type}" fields = f.send("#{type}_fields", new_object, child_index: id) do |builder| render(type.to_s + "_fields", f: builder) end link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")}) end |
#main_content_classes ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/helpers/rails_db/application_helper.rb', line 24 def main_content_classes if 'large-9 push-3 columns collapsed' else 'large-12 push-0 columns expanded' end end |
#params_to_hash(p) ⇒ Object
55 56 57 58 59 60 61 |
# File 'app/helpers/rails_db/application_helper.rb', line 55 def params_to_hash(p) if p.respond_to?(:to_unsafe_h) p.to_unsafe_h else p end end |
#rails_db_tables ⇒ Object
3 4 5 |
# File 'app/helpers/rails_db/application_helper.rb', line 3 def rails_db_tables RailsDb::Database.accessible_tables end |
#show_sidebar? ⇒ Boolean
32 33 34 35 |
# File 'app/helpers/rails_db/application_helper.rb', line 32 def return true if controller_name == 'dashboard' && action_name == 'index' ['sidebar_visible'] == 'true' end |
#sidebar_classes ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/helpers/rails_db/application_helper.rb', line 16 def if 'large-3 large-pull-9 columns' else 'large-3 large-pull-9 columns hide' end end |
#title(str) ⇒ Object
37 38 39 40 41 |
# File 'app/helpers/rails_db/application_helper.rb', line 37 def title(str) content_for :title do raw("#{str}"[0].upcase + "#{str}"[1..-1]) end end |