simple-pages-rails 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a232e5e770b76f97d0fa64159e653f0fd99b8fe
4
- data.tar.gz: ddaf8a379ad740a831ab4d45faa0a7554fdfab1c
3
+ metadata.gz: 3d41286186d3466f03371243b10c95a323973cb8
4
+ data.tar.gz: 1ff02604adfdbb548791dad6b005082010db2825
5
5
  SHA512:
6
- metadata.gz: 4dc3cd63b5a7bd56eb3df6b3d1026d1edddeaad8956399a7c53a03227b9ac6047eb65272ead98d24ff585ccf856407df3eb41a561970f3871f5532c21717f9a0
7
- data.tar.gz: b6f6646d52867145117491db1459f34db8b7100416db01d87e1b830e6056e9f18a6e3ab4afb36572f29ceb366023d13df24f133862ab2eea74e88c0a370c370d
6
+ metadata.gz: cdae70ecf369fcbc36c015a8aa6533b7c81ccaea1c6f4ee3374ee6d83630906f70bd93fe99401af2ad3a98a52b9467fb76ca091b22aa53ee12d8adb8ec89d928
7
+ data.tar.gz: af430b859d15ad2c71220a4e3f3018aebf80dad91181b1efa203a78e90c1ea1b0345b73a4ca4434e6b38d2dcf31454ea8dcb3f4867a9c894957ee972ec92dbf8
@@ -38,7 +38,7 @@ module SimplePages
38
38
  end
39
39
 
40
40
  def update
41
- @page.update_attributes params[:page]
41
+ @page.update_attributes page_params
42
42
  if @page.invalid?
43
43
  load_page_options
44
44
  end
@@ -52,8 +52,16 @@ module SimplePages
52
52
 
53
53
  protected
54
54
 
55
+ def page_params
56
+ if params.respond_to? :permit and params.has_key? :page
57
+ params.require(:page).permit(SimplePages.permitted_fields)
58
+ else
59
+ params[:page]
60
+ end
61
+ end
62
+
55
63
  def new_page
56
- @page = SimplePages::Page.new params[:page]
64
+ @page = SimplePages::Page.new page_params
57
65
  end
58
66
 
59
67
  def load_page_options
@@ -2,8 +2,6 @@ module SimplePages
2
2
  class Page < ActiveRecord::Base
3
3
  self.table_name = SimplePages.page_table_name
4
4
 
5
- attr_accessible :title, :excerpt, :content, :published_at, :layout_at
6
-
7
5
  validates :title, presence: true
8
6
 
9
7
  scope :published, lambda { where('published_at <= ?', Time.zone.now) }
@@ -15,17 +15,19 @@
15
15
  <td><%= t(page.layout_at, scope: 'simple_pages.layout_at') if page.layout_at? %></td>
16
16
  <td><%= page.author.name %></td>
17
17
  <td><%= publish_time(page.published_at, page.updated_at) %></td>
18
- <%= render_btn_group :td do |btn|
19
- if can? :show, page
20
- btn << link_to_show(page_path(page))
21
- end
22
- if can? :edit, page
23
- btn << link_to_edit(edit_page_path(page))
24
- end
25
- if can? :destroy, page
26
- btn << link_to_destroy(page_path(page))
27
- end
28
- end %>
18
+ <td class="actions">
19
+ <%= render_btn_group do |btn|
20
+ if can? :show, page
21
+ btn << link_to_show(page_path(page))
22
+ end
23
+ if can? :edit, page
24
+ btn << link_to_edit(edit_page_path(page))
25
+ end
26
+ if can? :destroy, page
27
+ btn << link_to_destroy(page_path(page))
28
+ end
29
+ end %>
30
+ </td>
29
31
  </tr>
30
32
  <% end %>
31
33
  </tbody>
@@ -1,4 +1,4 @@
1
- class AddGroupToSimplePages < ActiveRecord::Migration
1
+ class AddClusterToSimplePages < ActiveRecord::Migration
2
2
  def change
3
3
  add_column :simple_pages, :cluster, :string, after: :layout_at
4
4
  end
@@ -19,4 +19,7 @@ SimplePages.configure do |config|
19
19
 
20
20
  # set per page of pagination for page controller, default to 30.
21
21
  # config.pages_per_page = 30
22
+
23
+ # Add more allowed fields for strong paramters.
24
+ #config.permitted_fields += []
22
25
  end
@@ -1,3 +1,3 @@
1
1
  module SimplePagesRails
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'
3
3
  end
data/lib/simple_pages.rb CHANGED
@@ -36,6 +36,12 @@ module SimplePages
36
36
  mattr_accessor :pages_per_page
37
37
  @@pages_per_page = 30
38
38
 
39
+ mattr_accessor :permitted_fields
40
+ @@permitted_fields = [
41
+ :url, :title, :excerpt, :content, :owner, :published_at,
42
+ :layout_at, { cluster: [] }
43
+ ]
44
+
39
45
  def self.configure
40
46
  yield self
41
47
  end
@@ -6,12 +6,11 @@ module SimplePages
6
6
  extend ActiveSupport::Concern
7
7
  included do
8
8
  serialize :cluster
9
- attr_accessible :cluster
10
9
  end
11
10
 
12
11
  module ClassMethods
13
12
  def without_cluster
14
- where(cluster: "--- \n...\n")
13
+ where(cluster: [nil, "--- \n...\n"])
15
14
  end
16
15
 
17
16
  def with_cluster(name)
@@ -6,7 +6,6 @@ module SimplePages
6
6
  extend ActiveSupport::Concern
7
7
  included do
8
8
  attr_reader :owner
9
- attr_accessible :owner
10
9
  belongs_to :author, polymorphic: true
11
10
  end
12
11
 
@@ -5,7 +5,6 @@ module SimplePages
5
5
  module PageUrl
6
6
  extend ActiveSupport::Concern
7
7
  included do
8
- attr_accessible :url
9
8
  validates :url, format: { with: /\A([\w\-]{3,})\z/ }, allow_blank: true
10
9
  acts_as_url :title, sync_url: true, only_when_blank: true
11
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-pages-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tse-Ching Ho
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-13 00:00:00.000000000 Z
11
+ date: 2013-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -304,7 +304,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
304
304
  version: '0'
305
305
  requirements: []
306
306
  rubyforge_project:
307
- rubygems_version: 2.0.0
307
+ rubygems_version: 2.0.3
308
308
  signing_key:
309
309
  specification_version: 4
310
310
  summary: provides simple pages with rails engine