57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'app/controllers/concerns/effective/crud_controller/respond.rb', line 57
def respond_with_error(resource, action)
return if response.body.present?
flash.delete(:success)
flash.now[:danger] ||= resource_flash(:danger, resource, action)
respond_to do |format|
case action_name.to_sym
when :create
format.html { render :new }
when :update
format.html { render :edit }
when :destroy
format.html do
redirect_flash
redirect_to(resource_redirect_path(resource, action))
end
else
if template_present?(action)
format.html { render(action, locals: { action: action }) }
elsif request.referer.to_s.end_with?('/edit')
format.html { render :edit }
elsif request.referer.to_s.end_with?('/new')
format.html { render :new }
else
format.html do
redirect_flash
redirect_to(resource_redirect_path(resource, action))
end
end
end
format.js do
view = template_present?(action) ? action : :member_action
render(view, locals: { action: action })
end
end
end
|