lib/generators/scaffold_admin/templates/controller.rb in zscaffold_admin-0.0.1 vs lib/generators/scaffold_admin/templates/controller.rb in zscaffold_admin-0.0.2
- old
+ new
@@ -10,11 +10,11 @@
respond_with @<%= plural_name %>
end
def show
- @<%= singular_name %> = <%= class_name %>.find params[:id]
+ @<%= singular_name %> = <%= class_name %>.where(:id => params[:id]).first
respond_with @<%= singular_name %>
end
def new
@@ -22,39 +22,37 @@
respond_with @<%= singular_name %>
end
def edit
- @<%= singular_name %> = <%= class_name %>.find params[:id]
+ @<%= singular_name %> = <%= class_name %>.where(:id => params[:id]).first
respond_with @<%= singular_name %>
end
def create
- @<%= singular_name %> = <%= class_name %>.new params[:post]
+ @<%= singular_name %> = <%= class_name %>.new params[:<%= singular_name %>]
if @<%= singular_name %>.save
flash[:notice] = I18n.t :<%= singular_name %>_created
respond_with @<%= singular_name %>
else
- flash[:alert] = I18n.t :<%= singular_name %>_not_created
render :action => :new
end
end
def update
- @<%= singular_name %> = <%= class_name %>.find params[:id]
+ @<%= singular_name %> = <%= class_name %>.where(:id => params[:id]).first
- if @<%= singular_name %>.update_attributes params[:post]
+ if @<%= singular_name %>.update_attributes params[:<%= singular_name %>]
flash[:notice] = I18n.t :<%= singular_name %>_updated
respond_with @<%= singular_name %>
else
- flash[:alert] = I18n.t :<%= singular_name %>_not_updated
render :action => :edit
end
end
def destroy
- @<%= singular_name %> = <%= class_name %>.find params[:id]
+ @<%= singular_name %> = <%= class_name %>.where(:id => params[:id]).first
@<%= singular_name %>.destroy
respond_with @<%= singular_name %>
end