Sha256: dff927d7f2cff252e5eaba94db2e0ef9202ccb180e46ed7b69c42112af621274

Contents?: true

Size: 1.9 KB

Versions: 6

Compression:

Stored size: 1.9 KB

Contents

module RenderHelper

  def render_404
    respond_to do |format|
      format.html { render :file => "#{Rails.root}/public/404", :layout => true, :status => :not_found }
      format.any  { head :not_found }
    end
  end

  def handle_invalid_authenticity_token
    heading = I18n.t("status.invalid_token.heading")
    message = I18n.t("status.invalid_token.message")
    js_message = <<-eos
      showMessageModal('#{heading}','#{message}');
      notifyError('#{heading}','#{message}');
    eos
    respond_to do |format|
      format.html { render :status => 404 }
      format.js { render text: js_message }
    end
  end

  def render_or_redirect(error, redirect_url, action, notice=nil)
    respond_to do |format|
      format.html {
        if error
          render action: action
        else
          redirect_to redirect_url, notice: notice
        end
      }
      format.js {
        view_path = @resource_options && @resource_options[:view_path] ? "#{@resource_options[:js_view_path]}/#{params[:action]}" : params[:action].to_s
        render view_path
      }
    end
  end

  def render_accordingly
    respond_to do |format|
      format.html { get_collections and render params[:action].to_sym }
      format.js  { 
        view_path = @resource_options && @resource_options[:view_path] ? "#{@resource_options[:js_view_path]}/#{params[:action]}" : params[:action].to_sym
        render view_path
      }
    end
  end

  def render_show
    respond_to do |format|
      format.js { 
        js_view_path = @resource_options && @resource_options[:view_path] ? "#{@resource_options[:js_view_path]}/show" : :show
        render js_view_path
      }
    end
  end

  def render_row
    respond_to do |format|
      format.html {}
      format.js  { 
        js_view_path = @resource_options && @resource_options[:js_view_path] ? "#{@resource_options[:js_view_path]}/row" : :row 
        render js_view_path
      }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kuppayam-0.1.5 app/helpers/render_helper.rb
kuppayam-0.1.4dev app/helpers/render_helper.rb
kuppayam-0.1.4 app/helpers/render_helper.rb
kuppayam-0.1.3 app/helpers/render_helper.rb
kuppayam-0.1.2 app/helpers/render_helper.rb
kuppayam-0.1.1 app/helpers/render_helper.rb