templates/controller.rb in masterview_generator-0.3.1 vs templates/controller.rb in masterview_generator-0.3.2
- old
+ new
@@ -1,7 +1,7 @@
class <%= controller_class_name %>Controller < ApplicationController
-
+
<% unless suffix -%>
def index
list
render_action 'list'
end
@@ -15,36 +15,36 @@
def list<%= suffix %>
@<%= singular_name %>_pages, @<%= plural_name %> = paginate :<%= plural_name %>, :per_page => 10
end
def show<%= suffix %>
- @<%= singular_name %> = <%= model_name %>.find(@params['id'])
+ @<%= singular_name %> = <%= model_name %>.find(params['id'])
end
def new<%= suffix %>
- @<%= singular_name %> = <%= model_name %>.new(@params["<%= singular_name %>"])
-
- if @request.post? and @<%= singular_name %>.save
+ @<%= singular_name %> = <%= model_name %>.new(params["<%= singular_name %>"])
+
+ if request.post? and @<%= singular_name %>.save
flash[:notice] = '<%= model_name %> was successfully created.'
redirect_to :action => 'list<%= suffix %>'
- end
+ end
end
def edit<%= suffix %>
- @<%= singular_name %> = <%= model_name %>.find(@params['id'])
- @<%= singular_name %>.attributes = @params["<%= singular_name %>"]
- if @request.post? and @<%= singular_name %>.save
+ @<%= singular_name %> = <%= model_name %>.find(params['id'])
+ @<%= singular_name %>.attributes = params["<%= singular_name %>"]
+ if request.post? and @<%= singular_name %>.save
flash[:notice] = '<%= model_name %> was successfully updated.'
redirect_to :action => 'list<%= suffix %>'
- end
+ end
end
def destroy<%= suffix %>
- @<%= singular_name %> = <%= model_name %>.find(@params['id'])
- if @request.post?
+ @<%= singular_name %> = <%= model_name %>.find(params['id'])
+ if request.post?
@<%= singular_name %>.destroy
flash[:notice] = '<%= model_name %> was successfully deleted.'
redirect_to :action => 'list<%= suffix %>'
end
end
-
+
end