From d70238912c25c4102d986b39240e1d6e3502db5c Mon Sep 17 00:00:00 2001 From: yasushiito Date: Mon, 4 Jun 2012 17:03:50 +0900 Subject: [PATCH] add url validator --- Gemfile | 1 + Gemfile.lock | 3 +++ app/models/license.rb | 2 +- app/models/speech_balloon_template.rb | 2 +- app/views/panels/list.html.erb | 4 ++++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 512ff14c..c8c4f3e2 100644 --- a/Gemfile +++ b/Gemfile @@ -4,6 +4,7 @@ gem 'rails', '3.1.1' gem 'devise' gem 'aws-s3' gem 'validates_existence' +gem "validate_url" # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' diff --git a/Gemfile.lock b/Gemfile.lock index 6eb9cb63..fd212689 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -167,6 +167,8 @@ GEM uglifier (1.1.0) execjs (>= 0.3.0) multi_json (>= 1.0.2) + validate_url (0.2.0) + activemodel (>= 3.0.0) validates_existence (0.7.1) warden (1.1.0) rack (>= 1.0) @@ -199,5 +201,6 @@ DEPENDENCIES sass-rails (~> 3.1.4) sqlite3 uglifier (>= 1.0.3) + validate_url validates_existence webrat diff --git a/app/models/license.rb b/app/models/license.rb index 11252f83..3226b2d6 100644 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -2,7 +2,7 @@ class License < ActiveRecord::Base has_one :original_license has_one :common_license validates :name, :presence => true, :length => {:maximum => 50} - validates :url, :presence => true, :length => {:maximum => 200}, :uniqueness => true + validates :url, :presence => true, :length => {:maximum => 200}, :uniqueness => true, :url => {:allow_blank => true} def self.update_license cl l = License.find_by_url cl.url diff --git a/app/models/speech_balloon_template.rb b/app/models/speech_balloon_template.rb index a9a20ec5..710e99f1 100644 --- a/app/models/speech_balloon_template.rb +++ b/app/models/speech_balloon_template.rb @@ -17,7 +17,7 @@ class SpeechBalloonTemplate < ActiveRecord::Base def pic_rehash hash res = true - hash["templates"].each do |n, v| + (hash["templates"] || {}).each do |n, v| d = (v["balloon"] || {})["system_picture"] next nil if d.blank? sp = SystemPicture.store Base64.decode64(d.to_s) diff --git a/app/views/panels/list.html.erb b/app/views/panels/list.html.erb index 90f3ecc3..bc62b117 100644 --- a/app/views/panels/list.html.erb +++ b/app/views/panels/list.html.erb @@ -1,4 +1,8 @@

Listing panels

+<%= link_to 'open form', new_panel_path, :remote => true %> +
+ uploader +
-- 2.11.0