Skip to content

Instantly share code, notes, and snippets.

# Register your models here.
from django.contrib import admin
from .models import Question, Choice, Document
import os
from django.conf import settings
def handleBulkDelete(modeladmin, request, queryset):
for obj in queryset:
path = os.path.join(settings.MEDIA_ROOT, obj.docfile.name)
os.unlink(path)
Trying to figure out how to use section
3.2 Select Boxes for Dealing with Models
http://guides.rubyonrails.org/form_helpers.html
With my deeply nested models.
This takes all the group locations and lists them and lets me add them to the current provider under proivder locations.
Basically get what is working 'dumbly' on the controller side upon f.submit
@codejoy
codejoy / add_location.html.erb
Last active November 16, 2015 23:42
add_location.html.erb
<tr>
<td>
<% if @group_locations.count >0 %>
<%= select_tag "group_providers", options_from_collection_for_select(GroupLocation.all, 'id' ,@group_locations.map{ |j| j.dba }), :multiple => true%>
<% else %>
<%= select_tag "group_providers", "<option>Add new...</option>".html_safe, :multiple => true, :style => "width: 300px" %>
<% end %>
</td>
</tr>
NoMethodError in ProvidersController#create
To respond to a custom format, register it as a MIME type first: http://guides.rubyonrails.org/action_controller_overview.html#restful-downloads. If you meant to respond to a variant like :tablet or :phone, not a custom format, be sure to nest your variant response within a format response: format.html { |html| html.tablet { ... } }
Extracted source (around line #44):
42
43
44
45
46
47
<h3> TEST FOR ADD LOCATION </H3>
# Running:
E
Finished in 0.108843s, 9.1875 runs/s, 0.0000 assertions/s.
1) Error:
ProviderTermTest#test_terming_a_provider:
ActiveRecord::UnknownAttributeError: unknown attribute: provider
test/models/provider_term_test.rb:17:in `block in <class:ProviderTermTest>'
class CreateGroupsAddressJoinTable < ActiveRecord::Migration
def change
create_join_table(:groups, :addresses, 'group_locations') do |t|
# t.index [:group_id, :address_id]
t.index :address_id
t.index :group_id
t.integer :address_id
t.integer :group_id
end