Sha256: 7478dadf79c40dd4e14e9cf8c05aad58db2b4ba547358b04278412e8c12e5e66
Contents?: true
Size: 1.81 KB
Versions: 3
Compression:
Stored size: 1.81 KB
Contents
class <%= class_name %><%= step_alias.pluralize.camelize %>Controller < ApplicationController before_action :load_<%= file_path %> <%= step_alias.pluralize.upcase %> = %w(<%= steps.to_a.join(' ') %>) def edit if <%= file_path %>_<%= step_alias %>_model.editable? if <%= step_alias %>.present? render <%= step_alias %> else render "#{Rails.root.to_s}/public/404.html", :layout => false, :status => 404 end else redirect_to :back, :alert => I18n.t("<%= file_path %>.#{@<%= file_path %>.status}_editable_error") end end def update if <%= file_path %>_<%= step_alias %>_model.update_attributes(params[:<%= file_path %>]) if next_<%= step_alias %> && params[:commit].downcase.include?('continue') redirect_to edit_<%= file_path %>_<%= file_path %>_<%= step_alias %>_path(<%= file_path %>_<%= step_alias %>_model, next_<%= step_alias %>) else redirect_to <%= file_path %>_path(@<%= file_path %>) end else render <%= step_alias %>, :error => "Please complete all required fields" end end private def load_<%= file_path %> @<%= file_path %> = <%= file_path %>_<%= step_alias %>_model end def <%= file_path %>_<%= step_alias %>_model <%= file_path %>_class = "<%= class_name %>::#{<%= step_alias %>.camelcase}".constantize rescue <%= class_name %> <%= file_path %>_class.find(params[:<%= file_path %>_id]) end def <%= step_alias %> <%= step_alias.pluralize.upcase %>.find {|a_<%= step_alias %>| a_<%= step_alias %> == params[:id].to_s.downcase} end def next_<%= step_alias %> current_<%= step_alias %>_index = <%= step_alias.pluralize.upcase %>.index(<%= step_alias %>) next_<%= step_alias %> = <%= step_alias.pluralize.upcase %>[current_<%= step_alias %>_index+1] end end
Version data entries
3 entries across 3 versions & 1 rubygems