1
0
Fork 0
mirror of https://github.com/kbparagua/paloma synced 2023-03-27 23:21:17 -04:00

Update README.md

This commit is contained in:
Karl Bryan Paragua 2014-02-15 19:34:15 +08:00
parent a6e5d09ac3
commit d9d50aeb8f

View file

@ -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.