@active=ActiveDashboard.find(:first, :include => 'dashboard', :conditions => ['active_dashboards.dashboard_id=? AND active_dashboards.user_id=?', params[:id].to_i, current_user.id])
elsif params[:name]
@active=ActiveDashboard.find(:first, :include => 'dashboard', :conditions => ['dashboards.name=? AND active_dashboards.user_id=?', params[:name], current_user.id])
+ else
+ @active=ActiveDashboard.find(:first, :include => 'dashboard', :conditions => ['active_dashboards.user_id=?', current_user.id], :order => 'order_index ASC')
end
end
SECTION=Navigation::SECTION_RESOURCE
- verify :method => :post, :only => [:create, :update, :delete, :up, :down], :redirect_to => {:action => :index}
+ verify :method => :post, :only => [:create, :update, :delete, :up, :down, :unfollow], :redirect_to => {:action => :index}
before_filter :login_required
def index
redirect_to :action => 'index', :resource => params[:resource]
end
-
+ def unfollow
+ active_dashboard=ActiveDashboard.find(:first, :conditions => ['user_id=? AND dashboard_id=?', current_user.id, params[:id].to_i])
+ if active_dashboard
+ active_dashboard.destroy
+ end
+ redirect_to :action => :index, :resource => params[:resource]
+ end
private
|
<%= link_to 'Delete', {:action => 'delete', :id => active.dashboard_id, :resource => params[:resource]}, :method => :post, :confirm => 'Do you want to delete this dashboard ?', :id => "delete-#{u active.name}" %>
<% else %>
- <%= link_to 'Unfollow', {:action => 'unfollow', :id => active.dashboard_id}, :method => :post, :id => "hide-#{u active.name}" %>
+ <%= link_to 'Unfollow', {:action => 'unfollow', :id => active.dashboard_id, :resource => params[:resource]}, :method => :post, :id => "unfollow-#{u active.name}" %>
<% end %>
</td>
</tr>