Skip to content

Instantly share code, notes, and snippets.

@victorcreed
Created June 21, 2013 08:32
Show Gist options
  • Save victorcreed/5829767 to your computer and use it in GitHub Desktop.
Save victorcreed/5829767 to your computer and use it in GitHub Desktop.
another stupid experiment to lazy to write code for conventional action's
class Dashboard::JobDescriptionsController < Dashboard::BaseController
skip_authorization_check
before_filter only: [:new, :create] { @job_description = JobDescription.send(:new, ( params[:job_description] if params[:job_description]) ) }
before_filter only: [:edit, :update] { @job_description = JobDescription.find(params[:id]) }
before_filter only: [:create, :update] do
if @job_description.send((@job_description.new_record? ? :save : :update_attributes), ( @job_description.new_record? ? {validate: true} : params[:job_description] ))
redirect_to edit_dashboard_job_description_path(@job_description), notice: "record successfuly #{params[:action]}d"
else
render params[:action] == "create" ? :new : :edit
end
end
def index
@search = JobDescription.metasearch params[:job_description]
end
# if there is no file in view it will raise the error for action not found
def create; end; def update;end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment