0
votes

I have an application, on which I have two user interfaces.

The first one is for normal users and the second one is for iphone users.

Everything was working fine until i refactored my code within controller to use the respond_with declarative instead of respond_to.

The application is still working for the html interface(:format => :html) but not on the iphone interface(:format => :iphone).

On the iphone, when I do the following action (:index, :new, :edit, :show) it works.

But when i do (:create, :update, :destroy), I get errors saying the template is not found(create.iphone.haml for example).

On my controller I have

respond_to :html, :iphone

And then for example, the edit and the update action

def edit
    @refund = Refund.find(params[:id])
    respond_with(@refund)
  end
  def update
    @refund = Refund.find(params[:id])
    if @refund.update_attributes(params[:refund])
      flash[:notice] = 'Refund was successfully updated.'
    end
    respond_with(@refund, :location => project_refunds_path(@project))
  end

In fact, I would like the :iphone format is handle as :html is ... and not by calling the to_format method as it is specified into the doc.

2

2 Answers

1
votes

Solved it by myself.

Just need to add this to an initializer file :

ActionController::Responder.class_eval do
  alias :to_iphone :to_html
end
0
votes

What if you do:

respond_with(@refund, :location => project_refunds_path(@project)) do |format|
  format.iphone { whatever you had here before refactoring }
end