Browse files

Don't break validations yo!

  • Loading branch information...
1 parent c2ac076 commit 5431b30bb9da0fed8df8d62213a30bf4885afd45 @nakajima committed Jun 20, 2010
Showing with 7 additions and 3 deletions.
  1. +0 −1 app/controllers/bookmarklets_controller.rb
  2. +7 −2 app/models/bookmarklet.rb
View
1 app/controllers/bookmarklets_controller.rb
@@ -47,7 +47,6 @@ def authorize
# POST /bookmarklets.xml
def create
@bookmarklet = Bookmarklet.new(params[:bookmarklet])
-
respond_to do |format|
if @bookmarklet.save
flash[:notice] = 'Your bookmarklet was successfully created!'
View
9 app/models/bookmarklet.rb
@@ -12,6 +12,10 @@ def spam?
end
def code
+ self[:code]
+ end
+
+ def code_with_jquery
if jquery?
jquery = <<-JS
var _jq = document.createElement('script');
@@ -24,15 +28,16 @@ def code
wrapped_code = <<-JS
window.setTimeout(function() {
jQuery.noConflict();
- #{self[:code]}
+ #{code_without_jquery}
}, 10);
JS
[jquery, wrapped_code].join("\n")
else
- self[:code]
+ code_without_jquery
end
end
+ alias_method_chain :code, :jquery
def highlighted_code
self[:highlighted_code] || begin

0 comments on commit 5431b30

Please sign in to comment.