|
1 | 1 | class ActorsController < ApplicationController |
2 | | -# before_filter :find_actor, :only => [:show, :edit, :update, :destroy, :link, :unlink] |
3 | | - around_filter :neo_tx |
4 | | - |
5 | | - |
| 2 | + around_filter Neo4j::Rails::Transaction, :only => [:edit, :update, :destroy, :create] |
| 3 | + |
6 | 4 | def index |
7 | | - @actors = Actor.all.nodes |
8 | | - end |
9 | | - |
10 | | - def create |
11 | | - @actor = Actor.new |
12 | | - @actor.update(params[:actor]) |
13 | | - flash[:notice] = 'Actor was successfully created.' |
14 | | - redirect_to(@actor) |
15 | | - end |
16 | | - |
17 | | - def update |
18 | | - @actor.update(params[:actor]) |
19 | | - flash[:notice] = 'Actor was successfully updated.' |
20 | | - redirect_to(@actor) |
| 5 | + @actors = Actor.all |
21 | 6 | end |
22 | | - |
23 | | - def destroy |
24 | | - @actor.del |
25 | | - redirect_to(actors_url) |
26 | | - end |
27 | | - |
28 | | - def edit |
29 | | - end |
30 | | - |
| 7 | + |
31 | 8 | def show |
32 | | - @movies = Movie.all.nodes |
| 9 | + @actor = Actor.find(params[:id]) |
| 10 | + puts "FOUND ACTOR #{@actor}" |
33 | 11 | end |
34 | | - |
35 | | - def link |
36 | | - @movie = Neo4j.load_node(params[:movie_id]) |
37 | | - rel1 = @actor.acted_in.new(@movie) |
38 | | - rel1.character = params[:character] |
39 | | - redirect_to(@actor) |
| 12 | + |
| 13 | + def new |
| 14 | + @actor = Actor.new |
40 | 15 | end |
41 | 16 |
|
42 | | - def unlink |
43 | | - relationship = Neo4j.load_rel(params[:rel_id]) |
44 | | - relationship.del |
45 | | - redirect_to(@actor) |
| 17 | + def edit |
| 18 | + @actor = Actor.find(params[:id]) |
46 | 19 | end |
47 | | - |
48 | | - def new |
49 | | - @actor = Actor.value_object.new |
| 20 | + |
| 21 | + def create |
| 22 | + @actor = Actor.new(params[:actor]) |
| 23 | + |
| 24 | + if @actor.save |
| 25 | + redirect_to(@actor, :notice => 'Actor was successfully created.') |
| 26 | + else |
| 27 | + render :action => "new" |
| 28 | + end |
| 29 | + |
50 | 30 | end |
51 | | - |
52 | | - private |
53 | | - |
54 | | - def find_actor |
55 | | - @actor = Neo4j.load_node(params[:id]) |
| 31 | + |
| 32 | + |
| 33 | + def update |
| 34 | + @actor = Actor.find(params[:id]) |
| 35 | + if @actor.update_attributes(params[:actor]) |
| 36 | + redirect_to(@actor, :notice => 'Actor was successfully updated.') |
| 37 | + else |
| 38 | + render :action => "edit" |
| 39 | + end |
56 | 40 | end |
57 | | - |
58 | | - private |
59 | | - |
60 | | - def neo_tx |
61 | | - Neo4j::Transaction.new |
62 | | - @actor = Neo4j.load_node(params[:id]) if params[:id] |
63 | | - yield |
64 | | - Neo4j::Transaction.finish |
| 41 | + |
| 42 | + |
| 43 | + def destroy |
| 44 | + @actor = Actor.find(params[:id]) |
| 45 | + @actor.destroy |
| 46 | + redirect_to(actors_url) |
65 | 47 | end |
66 | 48 | end |
| 49 | + |
0 commit comments