Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

view_variant_responder

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

view_variant_responder

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= ViewVariantResponder

== Installation In your Gemfile, add this line: gem "view_variant_responder"

== Configuration This is only a module, to use it, you have to create your own responder:

lib/app_responder.rb

class AppResponder < ActionController::Responder include Responders::ViewVariantResponder end

If you're using any other responders, like Responders::FlashResponder, then include these there too.

Finally you need to configure your application to use it: require "app_responder" class ApplicationController < ActionController::Base self.responder = AppResponder end

== Usage Let's assume you want to show an overlay view of a post. Your controller already should look something like this: class PostsController < ApplicationController respond_to :html

def show
  @post = Post.find(params[:id])
  respond_with(@post)
end

end

Now you only need to add a separate view for the overlay

  • app/views/posts/show.html.erb - Your usual view
  • app/views/posts/show.overlay.html.haml - Your overlay view

To get this view using jquery for example, you'll do something like this: $.ajax({ url: "/posts/5", dataType: "html", headers: { "X-View-Variant": "overlay" }, success: function(content) { // Voila, your overlay content is now here } });

FAQs

Package last updated on 06 Apr 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc