Module: ExpressAdmin::StandardActions::InstanceMethods

Defined in:
lib/express_admin/standard_actions.rb

Instance Method Summary collapse

Instance Method Details

#create ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/express_admin/standard_actions.rb', line 92

def create
  build_resource(resource_params)
  if resource.save
    respond_to do |format|
      format.html { redirect_to resource_path }
    end
  else
    respond_to do |format|
      format.html { render :new, layout: defaults[:layout] }
    end
  end
end

#destroy ⇒ Object



133
134
135
136
137
138
139
# File 'lib/express_admin/standard_actions.rb', line 133

def destroy
  load_resource
  resource.destroy!
  respond_to do |format|
    format.html { redirect_to :index }
  end
end

#edit ⇒ Object



113
114
115
116
117
118
# File 'lib/express_admin/standard_actions.rb', line 113

def edit
  load_resource
  respond_to do |format|
    format.html { render :edit, layout: defaults[:layout] }
  end
end

#index ⇒ Object



77
78
79
80
81
82
83
# File 'lib/express_admin/standard_actions.rb', line 77

def index
  build_resource
  load_collection
  respond_to do |format|
    format.html { render :index, layout: defaults[:layout] }
  end
end

#new ⇒ Object



85
86
87
88
89
90
# File 'lib/express_admin/standard_actions.rb', line 85

def new
  build_resource
  respond_to do |format|
    format.html { render :new, layout: defaults[:layout] }
  end
end

#show ⇒ Object



105
106
107
108
109
110
111
# File 'lib/express_admin/standard_actions.rb', line 105

def show
  load_resource
  load_collection
  respond_to do |format|
    format.html { render :show, layout: defaults[:layout] }
  end
end

#update ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/express_admin/standard_actions.rb', line 120

def update
  load_resource
  if resource.update_attributes(resource_params)
    respond_to do |format|
      format.html { redirect_to resource_path }
    end
  else
    respond_to do |format|
      format.html { render :edit, layout: defaults[:layout] }
    end
  end
end