Skip to content
Snippets Groups Projects
Commit 1c05473e authored by Alexandre Peres Arias's avatar Alexandre Peres Arias
Browse files

fix orientdb connection to highlights management

parent 7b52dc30
No related branches found
No related tags found
No related merge requests found
...@@ -24,14 +24,21 @@ class Management::HighlightsController < ManagementController ...@@ -24,14 +24,21 @@ class Management::HighlightsController < ManagementController
def create def create
render :action => 'new' render :action => 'new'
@name = params[:name]
@url = params[:url]
db = OrientDb::HighlightRepository.new db = OrientDb::HighlightRepository.new
db.insert_data(@name,@url) db.insert_data(params[:name],params[:url])
end
def destroy
params[:name].each do |name|
db = OrientDb::HighlightRepository.new
db.destroy_data(name)
end
redirect_to management_highlights_index_path
end end
end end
...@@ -17,9 +17,10 @@ module OrientDb ...@@ -17,9 +17,10 @@ module OrientDb
return nil return nil
end end
def remove_data def destroy_data(name)
return @connection.command "DELETE VERTEX Highlight where name = '#{name}'"
#return @connection.command "DELETE FROM Highlight (name)" rescue
return nil
end end
end end
......
...@@ -6,24 +6,28 @@ ...@@ -6,24 +6,28 @@
<class="ls-title-2"><h3>Remover destaque</h3><br> <class="ls-title-2"><h3>Remover destaque</h3><br>
<fieldset>
<%= form_tag(:action => "destroy", :method => "get") do %>
<fieldset>
<!-- Exemplo com Radio button --> <!-- Exemplo com Radio button -->
<div class="ls-label col-md-5"> <div class="ls-label col-md-5">
<p>Escolha os destaques a remover:</p> <p>Escolha os destaques a remover:</p>
<% @highlights.each do |highlight| %> <% @highlights.each do |highlight| %>
<label class="ls-label-text"> <label class="ls-label-text">
<input type="radio" name="plataforms"> <input type="checkbox" name="name[]" value= <%= highlight['name'] %>>
<%= highlight['name'] %> <%= highlight['name'] %>
</label> </label>
<%end%> <%end%>
</div> </div>
</fieldset> </fieldset>
<div class="ls-actions-btn">
<%= submit_tag "Salvar", class: "ls-btn" %>
<%= link_to "Cancelar", management_highlights_index_path, class: "ls-btn-danger" %>
</div>
<%end%>
</div> </div>
<div class="ls-actions-btn">
<button class="ls-btn">Remover</button>
<%= link_to "Cancelar", management_highlights_index_path, class: "ls-btn-danger" %>
</div>
</body> </body>
...@@ -9,7 +9,7 @@ Rails.application.routes.draw do ...@@ -9,7 +9,7 @@ Rails.application.routes.draw do
namespace :management do namespace :management do
root 'welcome#index' root 'welcome#index'
post 'highlights/create' post 'highlights/create'
post 'highlights/destroy'
end end
root 'welcome#index' root 'welcome#index'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment