Module: ResourceControllerExtensions::FBML::ClassMethods

Defined in:
lib/resource_controller_extensions/fbml.rb

Instance Method Summary collapse

Instance Method Details

#init_default_actions_with_fbml(klass) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/resource_controller_extensions/fbml.rb', line 13

def init_default_actions_with_fbml(klass)
  init_default_actions_without_fbml(klass)
  klass.class_eval do
    index.wants.fbml
    new_action.wants.fbml
    edit.wants.fbml

    show do
      wants.fbml

      failure.wants.fbml { render :text => "Member object not found." }
    end

    create do
      flash "Successfully created!"
      wants.fbml { redirect_to object_url }

      failure.wants.fbml { render :action => "new" }
    end

    update do
      flash "Successfully updated!"
      wants.fbml { redirect_to object_url }

      failure.wants.fbml { render :action => "edit" }
    end

    destroy do
      flash "Successfully removed!"
      wants.fbml { redirect_to collection_url }
      failure.wants.fbml { redirect_to object_url }
    end
  end
end