polyblock 0.3.9 → 0.4.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: a144f379db0baf032b3ebfee8bd6d9e1efaa3aed
4
- data.tar.gz: afd53bafd7a88b3151c9f14bd8f748e5c703a378
3
+ metadata.gz: 5167a870413707136181d0211eeb379d516afdb2
4
+ data.tar.gz: 023d6566dddfbd6e236dce083d39175e206daadd
5
5
  SHA512:
6
- metadata.gz: 4aa9a039fe6a700224a7b956618881a880585bcd61ab7b2744140519972381f2759d848d7461c41cc909fff82a55c7ddd9cf2133f8d31c41987e322bd1231eb5
7
- data.tar.gz: 6f55bf7c4cf47a27611d6342d5c00774d4e7a9677d21370f3566b0b3960d75dc6ec3fb889c0f84d532e2442114a60dc2dfb4a4925b207ccfdb9733672cfae407
6
+ metadata.gz: 5ce4d7bdaaab32a4cb42decd7bef403fddc9943055bb822e8acb48474ba3f4f6f873689cea01c12a599705f68c8863a33655b1866bcce0f9e28df016b719ba16
7
+ data.tar.gz: 8dc0af791b25478ab1f2fc24bdbce31fb0abbe0ccd876e7971c7a83981ba0a0bd3f43e0308094ca83451dc3106c16d09e3276d5984086f9a6b2456f76cdcb1cd
@@ -6,13 +6,13 @@ module Polyblock
6
6
  def update
7
7
  if params.has_key? :pbs and params[:pbs].any?
8
8
  params[:pbs].each do |i, attrs|
9
- pb_attrs = {}
10
- pb_attrs[:id] = attrs[:id] if attrs.has_key?(:id) and !attrs[:id].blank?
11
- pb_attrs[:name] = attrs[:name] if attrs.has_key?(:name) and !attrs[:name].blank?
12
- pb = Block.find_or_initialize_by pb_attrs
13
- pb.id = nil if Block.find(pb_attrs[:id]).present? and pb.new_record?
14
- pb.content = attrs[:content]
15
- pb.save!
9
+ pb_find = Block.where(:id => attrs[:id])
10
+ attrs.delete(:id)
11
+ if pb_find.any? && pb_find.first.name == attrs[:name]
12
+ pb_find.first.update_attributes!(attrs)
13
+ else
14
+ Block.create! attrs
15
+ end
16
16
  end
17
17
  end
18
18
  render :text => "OK!"
@@ -1,3 +1,3 @@
1
1
  module Polyblock
2
- VERSION = "0.3.9"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -4,7 +4,7 @@
4
4
  = pb "Test", :editable => true
5
5
 
6
6
  %h3 New Polyblock
7
- = pb "New"
7
+ = pb "Neww", :editable => true
8
8
 
9
9
  %h3 Polyblock SimpleForm
10
10
  = simple_form_for @event do |f|
Binary file