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
2b23b1e43a
commit
8718284764
1 changed files with 46 additions and 1 deletions
47
README.md
47
README.md
|
|
@ -71,7 +71,7 @@ Directory Structure
|
|||
* [other_action].js
|
||||
* [more_action].js
|
||||
|
||||
Usage
|
||||
Generators
|
||||
-
|
||||
1. Generate a controller folder containing its required files:
|
||||
```
|
||||
|
|
@ -104,3 +104,48 @@ rails g paloma:add [controllers]/[action]
|
|||
|
||||
**Note:** You can directly run `rails g paloma:add [controllers]/[action]` even the controller folder is not yet
|
||||
existing on `paloma` folder. It will be created automatically.
|
||||
|
||||
|
||||
Advanced Callbacks
|
||||
-
|
||||
By default Paloma will execute the callback that matches the response's current controller and action if it finds one.
|
||||
For instance if the current response is from the `new` action of the `Users` controller, then Paloma will execute the callback
|
||||
named `users/new`.
|
||||
|
||||
You can manipulate callback behavior by using the `js_callback` command before the `render` or `redirect_to` command in your controllers.
|
||||
|
||||
1. Preventing the Callback to execute.
|
||||
|
||||
```ruby
|
||||
def destroy
|
||||
user = User.find params[:id]
|
||||
user.destroy
|
||||
|
||||
js_callback false
|
||||
end
|
||||
```
|
||||
|
||||
`[controllers]/destroy` callback will not be executed.
|
||||
|
||||
2. Using other action's callback from the same controller.
|
||||
|
||||
```ruby
|
||||
def edit
|
||||
@user = User.find params[:id]
|
||||
js_callback :new
|
||||
end
|
||||
```
|
||||
|
||||
This will execute `[controller]/new` callback instead of `[controller]/edit`.
|
||||
|
||||
3. Using other action's callback from other controller.
|
||||
|
||||
```ruby
|
||||
def index
|
||||
@users = User.all
|
||||
js_callback :controller => 'clients', :action => 'index'
|
||||
end
|
||||
```
|
||||
|
||||
This will execute `clients/index` callback instead of `[controller]/index`.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue