Class: LinksController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- LinksController
- Defined in:
- app/controllers/links_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
-
#edit ⇒ Object
Edit a link.
-
#remove_link ⇒ Object
Remove a link (drive popup).
- #show ⇒ Object
- #update ⇒ Object
Methods included from Zena::App
Instance Method Details
#create ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/links_controller.rb', line 33 def create attrs = filter_attributes(params['link']) @node.add_link(attrs.delete(:role), attrs) @node.save respond_to do |format| format.js end end |
#destroy ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/links_controller.rb', line 58 def destroy if params[:udom_id] # we need to replace @node by the other side of the link before # sending ajax response other = @link.other end @node.remove_link(@link) @node.save @node = other if other respond_to do |format| format.js end end |
#edit ⇒ Object
Edit a link. Called from drive popup.
10 11 12 13 14 15 16 |
# File 'app/controllers/links_controller.rb', line 10 def edit #puts "EDIT: #{@link['other_zip']}, #{@link['role']}, #{@link['status']}, #{@link['comment']}" respond_to do |format| format.html format.js { render :partial => 'form' } end end |
#remove_link ⇒ Object
Remove a link (drive popup).
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/links_controller.rb', line 45 def remove_link unless @node.can_drive? @node.errors.add('base', 'You do not have the rights to do this.') else @link_id = params.link_id @node.remove_link(@link_id) @node.save end respond_to do |format| format.js end end |
#show ⇒ Object
6 7 |
# File 'app/controllers/links_controller.rb', line 6 def show end |
#update ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/links_controller.rb', line 18 def update @link.update_attributes_with_transformations(params['link']) respond_to do |format| format.html do if @node.errors.empty? redirect_to :action => 'show' else render :action => 'edit' end end format.js { render :action => 'show' } end end |