From d9d50aeb8f309a1a954296e1eb0fbe9532e532da Mon Sep 17 00:00:00 2001 From: Karl Bryan Paragua Date: Sat, 15 Feb 2014 19:34:15 +0800 Subject: [PATCH] Update README.md --- README.md | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a07e64c..2d03747 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ Note: Using `Paloma.controller` method, you can access the same controller const ### Handling Actions -Every time a request to Paloma is made (A Rails Controller action is executed), an instance of a Paloma controller is created and a method responsible for the request will be invoked. +Every time a request to Paloma is made (A Rails Controller action is executed), an instance of a Paloma controller is created and the method responsible for the request will be invoked. ```javascript var ArticlesController = Paloma.controller('Articles'); @@ -129,6 +129,50 @@ UsersController.prototype.destroy = function(){ }; ``` + +## Advanced Usage + +You can manipulate what controller/action should Paloma execute using the `js` method. + +1. Changing controller + +```ruby +class UsersController < ApplicationController + def new + @user = User.new + js 'Accounts' # will use Accounts controller instead of Users controller + end +end +``` + + +2. Changing action + +You can use the symbol syntax: +```ruby +def new + @user = User.new + js :register # will execute register method instead of new +end +``` + +Or the string syntax: +```ruby +def new + @user = User.new + js '#register' +end +``` + +3. Changing controller and action + +```ruby +def new + @user = User.new + js 'Accounts#register' # will execute Accounts#register instead of Users#new +end +``` + ## Preventing Paloma Execution If you want to Paloma not to execute in a specific Rails Controller action you need to pass `false` as the Paloma parameter.