gary (owner)

Revisions

gist: 58542 Download_button fork
public
Public Clone URL: git://gist.github.com/58542.git
Embed All Files: show embed
subscriptions.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 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