mirror of
https://github.com/kbparagua/paloma
synced 2023-03-27 23:21:17 -04:00
Update README.md
This commit is contained in:
parent
a6e5d09ac3
commit
d9d50aeb8f
1 changed files with 45 additions and 1 deletions
46
README.md
46
README.md
|
@ -89,7 +89,7 @@ Note: Using `Paloma.controller` method, you can access the same controller const
|
||||||
|
|
||||||
### Handling Actions
|
### 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
|
```javascript
|
||||||
var ArticlesController = Paloma.controller('Articles');
|
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
|
## 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.
|
If you want to Paloma not to execute in a specific Rails Controller action you need to pass `false` as the Paloma parameter.
|
||||||
|
|
Loading…
Reference in a new issue