refinerycms 0.9.6.5 → 0.9.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/controllers/application.rb +1 -1
- data/app/controllers/application_controller.rb +1 -1
- data/config/environment.rb +2 -2
- data/config/environments/development.rb +1 -1
- data/config/environments/production.rb +1 -1
- data/config/preinitializer.rb +1 -1
- data/db/migrate/20100114092849_add_themes_table.rb +12 -12
- data/db/migrate/20100202034802_remove_custom_title_image_id_and_image_id_from_pages.rb +6 -6
- data/db/schema.rb +1 -1
- data/db/seeds.rb +2 -2
- data/lib/refinery_initializer.rb +1 -1
- data/public/javascripts/refinery/admin.js +61 -61
- data/readme.md +3 -3
- data/test/files/The world!.gif +0 -0
- data/test/files/car-wallpapers19.jpg +0 -0
- data/test/fixtures/images.yml +14 -0
- data/test/test_helper.rb +1 -1
- data/test/unit/image_test.rb +19 -8
- data/test/unit/page_part_test.rb +11 -11
- data/test/unit/page_test.rb +125 -125
- data/vendor/plugins/authentication/app/controllers/users_controller.rb +20 -20
- data/vendor/plugins/authentication/app/models/user.rb +5 -5
- data/vendor/plugins/authentication/app/views/user_mailer/reset_notification.html.erb +2 -2
- data/vendor/plugins/authentication/app/views/users/forgot.html.erb +1 -1
- data/vendor/plugins/authentication/app/views/users/reset.html.erb +2 -2
- data/vendor/plugins/authentication/config/routes.rb +4 -4
- data/vendor/plugins/dashboard/app/helpers/admin/dashboard_helper.rb +1 -1
- data/vendor/plugins/dashboard/app/views/admin/dashboard/_recent_activity.html.erb +1 -1
- data/vendor/plugins/dashboard/rails/init.rb +1 -1
- data/vendor/plugins/images/app/models/image.rb +14 -14
- data/vendor/plugins/images/app/views/admin/images/_form.html.erb +1 -8
- data/vendor/plugins/images/app/views/admin/images/insert.html.erb +1 -1
- data/vendor/plugins/inquiries/app/views/admin/inquiries/_inquiry.html.erb +3 -3
- data/vendor/plugins/inquiries/app/views/inquiries/new.html.erb +1 -1
- data/vendor/plugins/inquiries/app/views/inquiries/thank_you.html.erb +1 -1
- data/vendor/plugins/news/app/controllers/admin/news_items_controller.rb +1 -1
- data/vendor/plugins/news/app/controllers/news_items_controller.rb +1 -1
- data/vendor/plugins/news/app/views/news_items/index.html.erb +1 -1
- data/vendor/plugins/news/app/views/news_items/show.html.erb +1 -1
- data/vendor/plugins/pages/app/controllers/admin/pages_controller.rb +1 -1
- data/vendor/plugins/pages/app/models/page.rb +42 -42
- data/vendor/plugins/pages/app/models/page_part.rb +1 -1
- data/vendor/plugins/pages/app/presenters/page_presenter.rb +1 -1
- data/vendor/plugins/pages/app/views/admin/page_dialogs/_page_link.html.erb +1 -1
- data/vendor/plugins/pages/app/views/admin/pages/_form.html.erb +1 -1
- data/vendor/plugins/pages/app/views/admin/pages/_list.html.erb +1 -1
- data/vendor/plugins/pages/app/views/admin/pages/_page_part_field.html.erb +1 -1
- data/vendor/plugins/pages/app/views/pages/home.html.erb +1 -1
- data/vendor/plugins/pages/app/views/pages/show.html.erb +1 -1
- data/vendor/plugins/pages/rails/init.rb +5 -5
- data/vendor/plugins/rails_indexes/lib/indexer.rb +49 -47
- data/vendor/plugins/rails_indexes/tasks/indexer.rake +5 -3
- data/vendor/plugins/rails_indexes/test/fixtures/app/controllers/users_controller.rb +3 -3
- data/vendor/plugins/rails_indexes/test/fixtures/app/models/address.rb +2 -2
- data/vendor/plugins/rails_indexes/test/fixtures/app/models/company.rb +4 -4
- data/vendor/plugins/rails_indexes/test/fixtures/app/models/country.rb +1 -1
- data/vendor/plugins/rails_indexes/test/fixtures/app/models/freelancer.rb +1 -1
- data/vendor/plugins/rails_indexes/test/fixtures/app/models/gift.rb +4 -4
- data/vendor/plugins/rails_indexes/test/fixtures/app/models/god.rb +1 -1
- data/vendor/plugins/rails_indexes/test/fixtures/app/models/user.rb +7 -6
- data/vendor/plugins/rails_indexes/test/fixtures/app/sweepers/user_sweeper.rb +1 -1
- data/vendor/plugins/rails_indexes/test/fixtures/schema.rb +9 -9
- data/vendor/plugins/rails_indexes/test/rails_indexes_test.rb +18 -18
- data/vendor/plugins/refinery/app/views/admin/_head.html.erb +1 -1
- data/vendor/plugins/refinery/app/views/layouts/application.html.erb +1 -1
- data/vendor/plugins/refinery/app/views/shared/_content_page.html.erb +1 -1
- data/vendor/plugins/refinery/app/views/shared/_head.html.erb +1 -1
- data/vendor/plugins/refinery/app/views/shared/_header.html.erb +1 -1
- data/vendor/plugins/refinery/app/views/shared/_menu.html.erb +1 -1
- data/vendor/plugins/refinery/app/views/shared/_menu_branch.html.erb +5 -5
- data/vendor/plugins/refinery/app/views/shared/_submenu.html.erb +1 -1
- data/vendor/plugins/refinery/app/views/shared/admin/_continue_editing.html.erb +1 -1
- data/vendor/plugins/refinery/app/views/shared/admin/_error_messages_for.html.erb +1 -1
- data/vendor/plugins/refinery/app/views/shared/admin/_form_actions.html.erb +1 -1
- data/vendor/plugins/refinery/app/views/shared/admin/_image_picker.html.erb +27 -13
- data/vendor/plugins/refinery/app/views/shared/admin/_resource_picker.html.erb +1 -1
- data/vendor/plugins/refinery/app/views/shared/admin/_search.html.erb +1 -1
- data/vendor/plugins/refinery/app/views/shared/admin/_sortable_list.html.erb +1 -1
- data/vendor/plugins/refinery/lib/generators/refinery/templates/model.rb +1 -1
- data/vendor/plugins/refinery/lib/generators/refinery/templates/public_controller.rb +1 -1
- data/vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/_sortable_list.html.erb +1 -1
- data/vendor/plugins/refinery/lib/generators/refinery/templates/views/admin/index.html.erb +2 -2
- data/vendor/plugins/refinery/lib/generators/refinery/templates/views/index.html.erb +1 -1
- data/vendor/plugins/refinery/lib/generators/refinery/templates/views/show.html.erb +1 -1
- data/vendor/plugins/refinery/lib/refinery/activity.rb +1 -1
- data/vendor/plugins/refinery/lib/refinery/application_controller.rb +4 -4
- data/vendor/plugins/refinery/lib/refinery/application_helper.rb +1 -1
- data/vendor/plugins/refinery/lib/refinery/base_presenter.rb +1 -1
- data/vendor/plugins/refinery/lib/refinery/initializer.rb +1 -1
- data/vendor/plugins/refinery_dialogs/app/controllers/admin/dialogs_controller.rb +1 -1
- data/vendor/plugins/resources/app/models/resource.rb +8 -8
- data/vendor/plugins/resources/app/views/admin/resources/_form.html.erb +1 -1
- data/vendor/plugins/resources/app/views/admin/resources/index.html.erb +1 -1
- data/vendor/plugins/resources/app/views/admin/resources/insert.html.erb +1 -1
- data/vendor/plugins/resources/config/routes.rb +2 -2
- data/vendor/plugins/resources/rails/init.rb +1 -1
- data/vendor/plugins/themes/app/controllers/admin/themes_controller.rb +17 -17
- data/vendor/plugins/themes/app/models/theme.rb +40 -40
- data/vendor/plugins/themes/app/views/admin/themes/_form.html.erb +1 -1
- data/vendor/plugins/themes/config/routes.rb +2 -2
- data/vendor/plugins/themes/lib/theme_server.rb +26 -0
- data/vendor/plugins/themes/rails/init.rb +3 -1
- metadata +6 -3
- data/vendor/plugins/themes/app/controllers/themes_controller.rb +0 -45
@@ -28,11 +28,4 @@
|
|
28
28
|
<label>Current Image</label>
|
29
29
|
<%= image_fu @image, :medium, { :class => "brown_border" } %>
|
30
30
|
</div>
|
31
|
-
<% end %>
|
32
|
-
<% content_for :head do %>
|
33
|
-
<script type='text/javascript'>
|
34
|
-
$(document).ready(function(){
|
35
|
-
image_dialog.init();
|
36
|
-
});
|
37
|
-
</script>
|
38
|
-
<% end if from_dialog? %>
|
31
|
+
<% end %>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
<li class='clearfix record <%= cycle("on", "on-hover") %>'>
|
2
2
|
<span class='title'>
|
3
3
|
<span class='actions'>
|
4
|
-
<%= link_to refinery_icon_tag("#{inquiry.open? ? 'accept' : 'arrow_up'}.png"), {:action => "toggle_status", :id => inquiry.id},
|
4
|
+
<%= link_to refinery_icon_tag("#{inquiry.open? ? 'accept' : 'arrow_up'}.png"), {:action => "toggle_status", :id => inquiry.id},
|
5
5
|
{:title => "Move this inquiry to #{inquiry.open? ? 'closed' : 'open'}"} %>
|
6
|
-
<%= link_to refinery_icon_tag('email_open.png'), {:action => 'show', :id => inquiry.id},
|
6
|
+
<%= link_to refinery_icon_tag('email_open.png'), {:action => 'show', :id => inquiry.id},
|
7
7
|
{:title => "Read this inquiry"} -%>
|
8
|
-
<%= link_to refinery_icon_tag('delete.png'), admin_inquiry_url(inquiry), :class => "cancel confirm-delete",
|
8
|
+
<%= link_to refinery_icon_tag('delete.png'), admin_inquiry_url(inquiry), :class => "cancel confirm-delete",
|
9
9
|
:title => "Remove this inquiry forever" -%>
|
10
10
|
</span>
|
11
11
|
<%=h inquiry.name %>
|
@@ -1 +1 @@
|
|
1
|
-
<%= render :partial => "/shared/content_page" %>
|
1
|
+
<%= render :partial => "/shared/content_page" %>
|
@@ -4,26 +4,26 @@ class Page < ActiveRecord::Base
|
|
4
4
|
|
5
5
|
acts_as_tree :order => "position ASC", :include => [:children, :slugs]
|
6
6
|
|
7
|
-
|
7
|
+
# Docs for friendly_id http://github.com/norman/friendly_id
|
8
8
|
has_friendly_id :title, :use_slug => true
|
9
9
|
|
10
10
|
has_many :parts, :class_name => "PagePart", :order => "position ASC"
|
11
11
|
accepts_nested_attributes_for :parts, :allow_destroy => true
|
12
12
|
|
13
|
-
|
13
|
+
# Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
|
14
14
|
acts_as_indexed :fields => [:title, :meta_keywords, :meta_description, :custom_title, :browser_title, :all_page_part_content],
|
15
|
-
|
15
|
+
:index_file => [Rails.root.to_s, "tmp", "index"]
|
16
16
|
|
17
17
|
before_destroy :deletable?
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
# when a dialog pops up to link to a page, how many pages per page should there be
|
20
|
+
PAGES_PER_DIALOG = 14
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
# when listing pages out in the admin area, how many pages should show per page
|
23
|
+
PAGES_PER_ADMIN_INDEX = 20
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
# when collecting the pages path how is each of the pages seperated?
|
26
|
+
PATH_SEPERATOR = " - "
|
27
27
|
|
28
28
|
# Am I allowed to delete this page?
|
29
29
|
# If a link_url is set we don't want to break the link so we don't allow them to delete
|
@@ -38,13 +38,13 @@ class Page < ActiveRecord::Base
|
|
38
38
|
if self.deletable?
|
39
39
|
super
|
40
40
|
else
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
41
|
+
unless RAILS_ENV == "test"
|
42
|
+
# give useful feedback when trying to delete from console
|
43
|
+
puts "This page is not deletable. Please use .destroy! if you really want it deleted "
|
44
|
+
puts "unset .link_url," if self.link_url.present?
|
45
|
+
puts "unset .menu_match," if self.menu_match.present?
|
46
|
+
puts "set .deletable to true" unless self.deletable
|
47
|
+
end
|
48
48
|
|
49
49
|
return false
|
50
50
|
end
|
@@ -76,13 +76,13 @@ class Page < ActiveRecord::Base
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
79
|
+
# When this page is rendered in the navigation, where should it link?
|
80
|
+
# If a custom "link_url" is set, it uses that otherwise it defaults to a normal page URL.
|
81
|
+
# The "link_url" is often used to link to a plugin rather than a page.
|
82
|
+
#
|
83
|
+
# For example if I had a "Contact Us" page I don't want it to just render a contact us page
|
84
|
+
# I want it to show the Inquiries form so I can collect inquiries. So I would set the "link_url"
|
85
|
+
# to "/inquiries/new"
|
86
86
|
def url
|
87
87
|
if self.link_url.present?
|
88
88
|
self.link_url
|
@@ -91,29 +91,29 @@ class Page < ActiveRecord::Base
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
|
94
|
+
# Returns true if this page is "published"
|
95
95
|
def live?
|
96
96
|
not self.draft?
|
97
97
|
end
|
98
98
|
|
99
|
-
|
100
|
-
|
101
|
-
|
99
|
+
# Return true if this page can be shown in the navigation.
|
100
|
+
# If it's a draft or is set to not show in the menu it will return false.
|
101
|
+
# If any of the page's ancestors aren't to be shown in the menu then this page is not either.
|
102
102
|
def in_menu?
|
103
103
|
self.live? && self.show_in_menu? && !self.ancestors.any? { |a| !a.in_menu? }
|
104
104
|
end
|
105
105
|
|
106
|
-
|
106
|
+
# Returns true if this page is the home page or links to it.
|
107
107
|
def home?
|
108
108
|
self.link_url == "/"
|
109
109
|
end
|
110
110
|
|
111
|
-
|
111
|
+
# Returns all visible sibling pages that can be rendered for the menu
|
112
112
|
def shown_siblings
|
113
113
|
self.siblings.reject { |sibling| not sibling.in_menu? }
|
114
114
|
end
|
115
115
|
|
116
|
-
|
116
|
+
# Returns all the top level pages, usually to render the top level navigation.
|
117
117
|
def self.top_level(include_children = false)
|
118
118
|
include_associations = [:parts]
|
119
119
|
include_associations.push(:slugs) if self.class.methods.include? "find_one_with_friendly"
|
@@ -121,12 +121,12 @@ class Page < ActiveRecord::Base
|
|
121
121
|
find_all_by_parent_id(nil,:conditions => {:show_in_menu => true, :draft => false}, :order => "position ASC", :include => include_associations)
|
122
122
|
end
|
123
123
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
124
|
+
# Accessor method to get a page part from a page.
|
125
|
+
# Example:
|
126
|
+
#
|
127
|
+
# Page.first[:body]
|
128
|
+
#
|
129
|
+
# Will return the body page part of the first page.
|
130
130
|
def [](part_title)
|
131
131
|
# don't want to override a super method when trying to call a page part.
|
132
132
|
# the way that we call page parts seems flawed, will probably revert to page.parts[:title] in a future release.
|
@@ -140,13 +140,13 @@ class Page < ActiveRecord::Base
|
|
140
140
|
super_value
|
141
141
|
end
|
142
142
|
|
143
|
-
|
143
|
+
# In the admin area we use a slightly different title to inform the which pages are draft or hidden pages
|
144
144
|
def title_with_meta
|
145
|
-
|
146
|
-
|
147
|
-
|
145
|
+
title = self.title
|
146
|
+
title << " <em>(hidden)</em>" unless self.show_in_menu?
|
147
|
+
title << " <em>(draft)</em>" if self.draft?
|
148
148
|
|
149
|
-
|
149
|
+
title.strip
|
150
150
|
end
|
151
151
|
|
152
152
|
# Used to index all the content on this page so it can be easily searched.
|
@@ -154,7 +154,7 @@ class Page < ActiveRecord::Base
|
|
154
154
|
self.parts.collect {|p| p.body}.join(" ")
|
155
155
|
end
|
156
156
|
|
157
|
-
|
157
|
+
# Returns how many pages per page should there be when paginating pages
|
158
158
|
def self.per_page(dialog = false)
|
159
159
|
dialog ? PAGES_PER_DIALOG : PAGES_PER_ADMIN_INDEX
|
160
160
|
end
|
@@ -2,4 +2,4 @@
|
|
2
2
|
<li class='clearfix<%= " child#{child}" if child %><%= " linked" if linked%>' id="<%= dom_id(page_link) -%>">
|
3
3
|
<%= link_to page_link.title_with_meta, page_link.url, :title => 'Link to this Page', :rel => page_link.title, :class => 'page_link' %>
|
4
4
|
</li>
|
5
|
-
<%= render :partial => 'page_link', :collection => page_link.children, :locals => {:child => child ? (child+1) : 1} unless page_link.children.empty? %>
|
5
|
+
<%= render :partial => 'page_link', :collection => page_link.children, :locals => {:child => child ? (child+1) : 1} unless page_link.children.empty? %>
|
@@ -1,4 +1,4 @@
|
|
1
1
|
<div class='page_part field' id='<%= new_part ? "page_part_new_#{part_index}" : dom_id(part) %>'>
|
2
2
|
<%= hidden_field_tag "page[parts_attributes][#{part_index}][title]", part.title if new_part %>
|
3
3
|
<%= text_area_tag "page[parts_attributes][#{part_index}][body]", part.body, :rows => 20, :cols => 140, :class => 'wymeditor' %>
|
4
|
-
</div>
|
4
|
+
</div>
|
@@ -1 +1 @@
|
|
1
|
-
<%= render :partial => "/shared/content_page", :locals => {:show_submenu => false} %>
|
1
|
+
<%= render :partial => "/shared/content_page", :locals => {:show_submenu => false} %>
|
@@ -1 +1 @@
|
|
1
|
-
<%= render :partial => "/shared/content_page" %>
|
1
|
+
<%= render :partial => "/shared/content_page" %>
|
@@ -4,10 +4,10 @@ Refinery::Plugin.register do |plugin|
|
|
4
4
|
plugin.version = 1.0
|
5
5
|
plugin.menu_match = /admin\/((pages)|(page_dialogs)|(page_parts))$/
|
6
6
|
plugin.activity = {
|
7
|
-
:class => Page,
|
8
|
-
:url_prefix => "edit",
|
9
|
-
:title => "title",
|
10
|
-
:created_image => "page_add.png",
|
7
|
+
:class => Page,
|
8
|
+
:url_prefix => "edit",
|
9
|
+
:title => "title",
|
10
|
+
:created_image => "page_add.png",
|
11
11
|
:updated_image => "page_edit.png"
|
12
12
|
}
|
13
|
-
end
|
13
|
+
end
|
@@ -113,49 +113,8 @@ module Indexer
|
|
113
113
|
@indexes_required[table_name] += [primary_key] unless @indexes_required[table_name].include?(primary_key)
|
114
114
|
end
|
115
115
|
|
116
|
-
|
117
|
-
if matches = find_regexp.match(line)
|
116
|
+
check_line_for_find_indexes(file_name, line)
|
118
117
|
|
119
|
-
model_name, column_names, options = matches[1], matches[6], matches[7]
|
120
|
-
|
121
|
-
if model_name == "self"
|
122
|
-
model_name = File.basename(file_name).sub(/\.rb$/,'').camelize
|
123
|
-
table_name = model_name.constantize.table_name
|
124
|
-
else
|
125
|
-
if model_name.respond_to?(:constantize)
|
126
|
-
if model_name.constantize.respond_to?(:table_name)
|
127
|
-
table_name = model_name.constantize.table_name
|
128
|
-
else
|
129
|
-
#puts "Unable to get the table_name for #{model_name.to_s}. it could be an ActiveResource"
|
130
|
-
next
|
131
|
-
end
|
132
|
-
else
|
133
|
-
#puts "Unable to constantize #{model_name.to_s}, if you are sure that #{model_name.to_s} is a valid class name, please file an issue on\nhttp://github.com/eladmeidar/rails_indexes\nPlease supply the relevant code as well, thanks. =)"
|
134
|
-
next
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
primary_key = model_name.constantize.primary_key
|
139
|
-
@indexes_required[table_name] += [primary_key] unless @indexes_required[table_name].include?(primary_key)
|
140
|
-
|
141
|
-
if column_names.present?
|
142
|
-
column_names = column_names.split('_and_')
|
143
|
-
|
144
|
-
# remove find_by_sql references.
|
145
|
-
column_names.delete("sql")
|
146
|
-
|
147
|
-
column_names = model_name.constantize.column_names & column_names
|
148
|
-
|
149
|
-
# Check if there were more than 1 column
|
150
|
-
if column_names.size == 1
|
151
|
-
column_name = column_names.first
|
152
|
-
@indexes_required[table_name] += [column_name] unless @indexes_required[table_name].include?(column_name)
|
153
|
-
else
|
154
|
-
@indexes_required[table_name] += [column_names] unless @indexes_required[table_name].include?(column_names)
|
155
|
-
@indexes_required[table_name] += [column_names.reverse] unless @indexes_required[table_name].include?(column_names.reverse)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
118
|
end
|
160
119
|
end
|
161
120
|
|
@@ -180,6 +139,53 @@ module Indexer
|
|
180
139
|
@indexes_required
|
181
140
|
end
|
182
141
|
|
142
|
+
|
143
|
+
def self.check_line_for_find_indexes(file_name, line)
|
144
|
+
find_regexp = Regexp.new(/([A-Z]{1}[A-Za-z]+|self).(find){1}((_all){0,1}(_by_){0,1}([A-Za-z_]+))?\(([0-9A-Za-z"\':=>. \[\]{},]*)\)/)
|
145
|
+
if matches = find_regexp.match(line)
|
146
|
+
|
147
|
+
model_name, column_names, options = matches[1], matches[6], matches[7]
|
148
|
+
|
149
|
+
if model_name == "self"
|
150
|
+
model_name = File.basename(file_name).sub(/\.rb$/,'').camelize
|
151
|
+
table_name = model_name.constantize.table_name
|
152
|
+
else
|
153
|
+
if model_name.respond_to?(:constantize)
|
154
|
+
if model_name.constantize.respond_to?(:table_name)
|
155
|
+
table_name = model_name.constantize.table_name
|
156
|
+
else
|
157
|
+
#puts "Unable to get the table_name for #{model_name.to_s}. it could be an ActiveResource"
|
158
|
+
next
|
159
|
+
end
|
160
|
+
else
|
161
|
+
#puts "Unable to constantize #{model_name.to_s}, if you are sure that #{model_name.to_s} is a valid class name, please file an issue on\nhttp://github.com/eladmeidar/rails_indexes\nPlease supply the relevant code as well, thanks. =)"
|
162
|
+
next
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
primary_key = model_name.constantize.primary_key
|
167
|
+
@indexes_required[table_name] += [primary_key] unless @indexes_required[table_name].include?(primary_key)
|
168
|
+
|
169
|
+
if column_names.present?
|
170
|
+
column_names = column_names.split('_and_')
|
171
|
+
|
172
|
+
# remove find_by_sql references.
|
173
|
+
column_names.delete("sql")
|
174
|
+
|
175
|
+
column_names = model_name.constantize.column_names & column_names
|
176
|
+
|
177
|
+
# Check if there were more than 1 column
|
178
|
+
if column_names.size == 1
|
179
|
+
column_name = column_names.first
|
180
|
+
@indexes_required[table_name] += [column_name] unless @indexes_required[table_name].include?(column_name)
|
181
|
+
else
|
182
|
+
@indexes_required[table_name] += [column_names] unless @indexes_required[table_name].include?(column_names)
|
183
|
+
@indexes_required[table_name] += [column_names.reverse] unless @indexes_required[table_name].include?(column_names.reverse)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
183
189
|
def self.key_exists?(table,key_columns)
|
184
190
|
result = (key_columns.to_a - ActiveRecord::Base.connection.indexes(table).map { |i| i.columns }.flatten)
|
185
191
|
result.empty?
|
@@ -234,8 +240,6 @@ EOM
|
|
234
240
|
|
235
241
|
puts "## Drop this into a file in db/migrate ##"
|
236
242
|
puts migration
|
237
|
-
else
|
238
|
-
puts "Didn't find any models requiring indexing in your app/models directory."
|
239
243
|
end
|
240
244
|
end
|
241
245
|
|
@@ -293,11 +297,9 @@ EOM
|
|
293
297
|
|
294
298
|
puts "## Drop this into a file in db/migrate ##"
|
295
299
|
puts migration
|
296
|
-
else
|
297
|
-
puts "Didn't find any models requiring indexing in your app/models directory."
|
298
300
|
end
|
299
301
|
end
|
300
302
|
else
|
301
303
|
find_indexes
|
302
304
|
end
|
303
|
-
end
|
305
|
+
end
|
@@ -1,16 +1,18 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "../lib/indexer.rb")
|
2
|
+
|
1
3
|
namespace :db do
|
2
4
|
desc "collect indexes based on AR::Base.find calls."
|
3
5
|
task :show_me_ar_find_indexes => :environment do
|
4
6
|
Indexer.ar_find_indexes
|
5
7
|
end
|
6
|
-
|
8
|
+
|
7
9
|
desc "scan for possible required indexes"
|
8
10
|
task :show_me_some_indexes => :environment do
|
9
11
|
# Indexer.indexes_list
|
10
12
|
puts "Sorry, simple report is deprecated.\nuse rake db:show_me_a_migration or db:show_me_ar_find_indexes instead"
|
11
13
|
end
|
12
|
-
|
14
|
+
|
13
15
|
task :show_me_a_migration => :environment do
|
14
16
|
Indexer.simple_migration
|
15
17
|
end
|
16
|
-
end
|
18
|
+
end
|