meskyanichi-make_sortable 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -54,7 +54,7 @@ since you will need the index to determine the position of each record.
54
54
 
55
55
  That's it! Just click on the up or down button and it works.
56
56
 
57
- ==== What I always like to do is go into my mode, in this case, post.rb and add a default_scope:
57
+ ==== What I always like to do is go into my model, in this case, post.rb and add a default_scope:
58
58
 
59
59
  class Post < ActiveRecord::Base
60
60
  default_scope :order => :position
@@ -173,17 +173,21 @@ The above would provide you with 4 methods. These methods will be available to a
173
173
  - link_up_for_posts_position :object, :index, :html
174
174
  - link_down_for_posts_position :object, :index, :html
175
175
 
176
- If you for any reason need these methods inside a different controller, see the (above) topic:
176
+
177
+
178
+ Note that it's highly recommended to use the button_up and button_down methods. The link_up and link_down methods rely on Javascript.
179
+
180
+ If you for any reason need these methods available to a different controllers' views, see the (above) topic:
177
181
  "Specifying the :controller and :model options with make_sortable()"
178
182
 
179
183
  All 4 methods take the same arguments. Let me explain.
180
184
 
181
- ==== Argument: :object
185
+ ==== Argument :object
182
186
  This is a required argument. It expects you to provide the object/(array) on which you are performing the .each_with_index method.
183
187
 
184
188
  button_up_for_posts_position(:object => @posts)
185
189
 
186
- ==== Argument: :index
190
+ ==== Argument :index
187
191
  This is a required argument. It expects you to provide the index of the currently looping object(record). You can get this index when calling .each_with_index on the @posts object/(array)
188
192
 
189
193
  @posts.each_with_index do |post, index|
@@ -193,7 +197,7 @@ This is a required argument. It expects you to provide the index of the currentl
193
197
  The example above is basically all that's required to get the sorting gem working. The :html argument is optional.
194
198
  Basically, it's like the "link_to()" and "button_to()" methods in the Rails-Core. With it you can provide any additional HTML attributes to the HTML tag.
195
199
 
196
- ==== Argument: :html
200
+ ==== Argument :html
197
201
 
198
202
  button_up_for_posts_position(:object => @posts, :index => index, :html => {
199
203
  :id => "post_id_#{post.id}",
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -36,11 +36,19 @@ module MakeSortable
36
36
  else
37
37
  if view_options[:index] > 0
38
38
 
39
+ unless view_options[:html]
40
+ view_options[:html] = {:method => :post}
41
+ end
42
+
43
+ unless view_options[:html][:method]
44
+ view_options[:html][:method] = :post
45
+ end
46
+
39
47
  link_to( view_options[:name] || "up",
40
48
  {:controller => options[:controller],
41
49
  :action => options[:attribute],
42
50
  options[:controller].to_sym => view_options[:object].swap(view_options[:index],
43
- view_options[:index] -1 )}, view_options[:html] || {})
51
+ view_options[:index] -1 )}, view_options[:html])
44
52
 
45
53
  end
46
54
  end
@@ -60,12 +68,20 @@ module MakeSortable
60
68
  end
61
69
  else
62
70
  if view_options[:index] < view_options[:object].length - 1
71
+
72
+ unless view_options[:html]
73
+ view_options[:html] = {:method => :post}
74
+ end
75
+
76
+ unless view_options[:html][:method]
77
+ view_options[:html][:method] = :post
78
+ end
63
79
 
64
80
  link_to( view_options[:name] || "down",
65
81
  {:controller => options[:controller],
66
82
  :action => options[:attribute],
67
83
  options[:controller].to_sym => view_options[:object].swap(view_options[:index],
68
- view_options[:index] +1 )}, view_options[:html] || {})
84
+ view_options[:index] +1 )}, view_options[:html])
69
85
 
70
86
  end
71
87
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{make_sortable}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael van Rooijen", "Jeff Kreeftmeijer"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meskyanichi-make_sortable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael van Rooijen