lib/generators/adhoc/portfolio/templates/controller.rb in adhoc-generators-0.0.4 vs lib/generators/adhoc/portfolio/templates/controller.rb in adhoc-generators-0.0.5

- old
+ new

@@ -1,3 +1,15 @@ -class <%= plural_class_name %>Controller < ApplicationController - <%= controller_methods :actions %> +class <%= plural_model_name %>Controller < ApplicationController + before_action :set_<%= instance_name %>, only: [:show, :edit, :update, :destroy] + + <%= controller_methods %> + + private + + def set_<%= instance_name %> + @<%= instance_name %> = <%= model_name %>.where(id: params[:id]).first + end + + def <%= instance_name %>_params + params.require(:<%= instance_name %>).permit(<%= attributes.map { |a| ":#{a.name}" }.join(", ") %>) + end end \ No newline at end of file