Cross Reference:
xref
: /
ontohub
/
app
/
controllers
/
links_controller.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
links_controller.rb revision 03f646de2163bd949f5170ec851a86dc0d3ca064
#
# Controller for Links
#
class
LinksController
<
InheritedResources
::
Base
respond_to
:
json
, :
xml
has_pagination
has_scope
:
search
load_and_authorize_resource
:
except
=> [:
index
, :
show
]
def
index
super
do
|
format
|
format.html
do
@
search
=
params
[:
search
]
@
search
=
nil
if
@
search.blank
?
end
end
end
def
new
@
version
=
build_resource.versions.build
end
def
create
@
version
=
build_resource.versions.first
@
version.source
=
Ontology.find
(
params
[:
link
][:
source_id
])
.versions.current
@
version.target
=
Ontology.find
(
params
[:
link
][:
target_id
])
.versions.current
super
end
def
update_version
@
version
=
resource.versions.current.dup
@
version.version
_number
= @
version.version
_number
+
1
@
version.save
redirect_to
edit_link_link_version_path
(
resource
, @
version
)
end
private
def
build_resource
return
@
link
if
@
link
@
link
=
Link.new
params
[:
link
]
end
end