This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.rails.allowAction = (link) -> | |
return true unless link.attr('data-confirm') | |
$.rails.showConfirmDialog(link) # look bellow for implementations | |
false # always stops the action since code runs asynchronously | |
$.rails.confirmed = (link) -> | |
link.removeAttr('data-confirm') | |
link.trigger('click.rails') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This doc: | |
http://api.rubyonrails.org/classes/BigDecimal.html#method-i-as_json | |
says: | |
A BigDecimal would be naturally represented as a JSON number. Most libraries, however, parse non-integer JSON numbers directly as floats. Clients using those libraries would get in general a wrong number and no way to recover other than manually inspecting the string with the JSON code itself. | |
That’s why a JSON string is returned. The JSON literal is not numeric, but if the other end knows by contract that the data is supposed to be a BigDecimal, it still has the chance to post-process the string and get the real value. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Business | |
many :invoices | |
end | |
class Invoice | |
property :ref, String | |
property :total, BigDecimal | |
property :paid_total, BigDecimal | |
one :buinsess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I think it's ok to replace: | |
self.send(:update_without_callbacks) | |
with: | |
LineItem.skip_callback(:save) {save} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostsController < ActionController::Base | |
def create | |
SomePOROThatDoesNotDependOnRails.run(params) | |
end | |
def update | |
SomePOROThatDoesNotDependOnRails.run(params) | |
end | |
private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using ts 1.3.16 on a rails 2.3.8 app: | |
Here is the index: | |
define_index do | |
indexes name, :sortable=>:true | |
indexes zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>>> This is a normal request to the url via a browser: | |
Started GET "/api/bulk?events=all" for 127.0.0.1 at Wed Oct 19 09:56:48 -0400 2011 | |
Processing by Bulk::ApiController#get as HTML | |
Parameters: {"events"=>"all"} | |
Event Load (0.6ms) SELECT `events`.* FROM `events` LIMIT 100 | |
Completed 200 OK in 289ms (Views: 105.6ms | ActiveRecord: 0.6ms | Sphinx: 0.0ms) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bike | |
def price | |
send "price_for_#{@bike_type}" | |
end | |
def price_for_a | |
end | |
def price_for_b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_d | |
index 24ebb8f..206959b 100644 | |
--- a/actionpack/lib/action_dispatch/middleware/cookies.rb | |
+++ b/actionpack/lib/action_dispatch/middleware/cookies.rb | |
@@ -167,7 +167,7 @@ module ActionDispatch | |
handle_options(options) | |
- @set_cookies[key] = options | |
+ @set_cookies[key.to_s] = options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActionDispatch | |
class Cookies | |
class CookieJar < Hash #:nodoc: | |
# Sets the cookie named +name+. The second argument may be the very cookie |