You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are a couple of places where respond_to blocks are hard-coded
to only handle HTML and JS responses.
As a result, it is unnecessarily difficult to implement a hobo controller
that can handle JSON requests.
Really, it should work like any other controller does where all you have
to do is add this to your controller declaration:
respond_to :json, :html
Instead, one has to over-ride every single controller action manually and put
in your own respond_to block. What's that use of Hobo at that point?
In some places, Hobo just assumes that if the request is not an AJAX request,
the response should be HTML.
The specific places where this assumption is hard-coded are:
Hobo::Controller::Model#permission_denied
Hobo::Controller::Model#create_response
Hobo::Controller::Model#update_response
Hobo::Controller::Model#do_creator_response
Additionally, it often determines if it should respond with js not by looking at the requested response format but instead by checking for the mere existence of params[:render].
e.g.: In Hobo::Controller::Model#update_response
if params[:render]
if (params[:render_options] && params[:render_options][:errors_ok]) || valid
hobo_ajax_response
# Maybe no ajax requests were made
render :nothing => true unless performed?
else
errors = @this.errors.full_messages.join('\n')
message = ht(:"#{@this.class.to_s.underscore}.messages.update.error", :default=>["There was a problem with that change\\n#{errors}"], :errors=>errors)
render :js => "alert(#{message.to_json});\n"
end
else
I have implemented a kludgey workaround in my hobo_turbo gem (include HoboTurbo::Workarounds::JsonResponseFix) but I'd prefer
that we get this fixed properly since my workaround does not handle custom
actions created with say index_action or show_action or auto_actions_for
The text was updated successfully, but these errors were encountered:
There are a couple of places where respond_to blocks are hard-coded
to only handle HTML and JS responses.
As a result, it is unnecessarily difficult to implement a hobo controller
that can handle JSON requests.
Really, it should work like any other controller does where all you have
to do is add this to your controller declaration:
respond_to :json, :html
Instead, one has to over-ride every single controller action manually and put
in your own respond_to block. What's that use of Hobo at that point?
In some places, Hobo just assumes that if the request is not an AJAX request,
the response should be HTML.
The specific places where this assumption is hard-coded are:
Hobo::Controller::Model#permission_denied
Hobo::Controller::Model#create_response
Hobo::Controller::Model#update_response
Hobo::Controller::Model#do_creator_response
Additionally, it often determines if it should respond with js not by looking at the requested response format but instead by checking for the mere existence of params[:render].
e.g.: In Hobo::Controller::Model#update_response
I have implemented a kludgey workaround in my hobo_turbo gem (include HoboTurbo::Workarounds::JsonResponseFix) but I'd prefer
that we get this fixed properly since my workaround does not handle custom
actions created with say index_action or show_action or auto_actions_for
The text was updated successfully, but these errors were encountered: