gary (owner)

Revisions

gist: 49567 Download_button fork
public
Public Clone URL: git://gist.github.com/49567.git
Embed All Files: show embed
generic form #
1
2
    = form_for @subscription, :action => url(:create_mobile_alert_subscription), :method => 'post' do
      = partial subscription_for_mobile_alert(@mobile_alert), :with => @subscription
partial for each Subscription type (sports, in this case) #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
%p.subscription_parameter_description
  Begin by typing the name of a team.
%table#teams_autocomplete_fields.subscription_parameter_list
  %tr
    %td
      %b
        Teams
  %tr
    %td
      - unless @subscription.teams.empty?
        - @subscription.teams.each do |team| |
          = text_field :position
      - else
        = text_field :position
Ruby #
1
2
3
4
5
6
7
8
9
10
11
    def create(subscription)
      # raises BadRequest exception... but if the arg is renamed to sports_subscription...
      @subscription = Subscription.new(subscription)
      if @subscription.save
        redirect(url(:mobile_alert_subscriptions))
      else
        message[:error] = 'Failed to be subscribe you'
        render :new
      end
    end