Created
February 5, 2009 04:00
-
-
Save gary/58542 to your computer and use it in GitHub Desktop.
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
# make life in JavaScript more readable by wrapping the Objects needed | |
# to update after a {successful,failed} save in a named Hash, which will | |
# serialize an Object with key-named properties. big slick. | |
def pretty_json(subscription, params={}) | |
# camelCased ruby is heresy, and is merely following the naming | |
# conventions of its destination environment | |
if subscription.valid? | |
{ :newspaperName => @mobile_alert.newspaper.name, | |
:mobileAlert => @mobile_alert, | |
:editLink => edit_subscription_modal_window(@mobile_alert.id, | |
subscription.id), | |
:destroyLink => url(:destroy_mobile_alert_subscription, | |
:mobile_alert_id => @mobile_alert.id, | |
:id => subscription.id) | |
} | |
else | |
{ :validation => subscription.errors.to_a } | |
end.merge(params) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment