As a senior Ruby on Rails developer with architecture skills, following tasks step by step. After completing each task, update the implementation summary and memory bank (as defined in @memory-bank.mdc) before proceeding. Use context7
for relevant documentation.
- TrunkBlocklistsController with RESTful actions for client management. Follow guidelines from
docs/form_styling.md
Description: Create a controller for managing trunkBlocklists records with RESTful actions following Ruby on Rails conventions.
Technical Approach:
- Generate TrunkBlocklistsController with standard RESTful actions
- Use strong parameters pattern for secure parameter handling
- Add pagination with Kaminari
- Implement search functionality with Ransack
- Add proper error handling and flash messages
- Add links to trunk_blocklists from
app/views/trunks/index.html.erb
andapp/views/trunks/show.html.erb
Dependencies:
app/models/trunk.rb
modelapp/models/trunk_blocklist.rb
model
Acceptance Criteria:
- Controller provides index, show, new, create, edit, update, and destroy actions
- Index action supports pagination (max 100 per page) and search
- All actions have proper authorization checks
- Proper error handling and user feedback
Testing Considerations:
- Request specs for all controller actions according to @rspec.mdc
- Edge case handling (invalid params, not found, etc.)
- Test pagination and search functionality
TODO Checklist:
- Generate TrunkBlocklistsController with RESTful actions
- Implement index action with pagination and search
- Implement show action
- Implement edit and update actions
- Implement destroy action with proper validations
- Implement strong parameters
- Add error handling and flash messages
- Write request specs for all actions
- Document controller actions and API endpoints
Task: create ThingsController
Workflow:
- Read
db/schema.rb
about fields for Thing - Create ThingsController like:
# frozen_string_literal: true
class ThingsController < ApplicationController
before_action :set_trunk, only: %i[show edit update destroy]
def index
@q = Thing.ransack(params[:q])
per_page = [params[:per_page]&.to_i || 100, 100].min
@trunks = @q.result.page(params[:page]).per(per_page)
end
...
private
def things_params
params.require(:thing).permit(:name)
end
end
- Add search params for ransack to model
app/models/thing.rb
# frozen_string_literal: true
class Thing < ApplicationRecord
# Define ransackable attributes for secure searching and sorting
def self.ransackable_attributes(_auth_object = nil)
%w[name created_at updated_at]
end
# Define ransackable associations
def self.ransackable_associations(_auth_object = nil)
%w[...]
end
end
- Create appropriate views with tailwindcss styles with
emerald
colour as base. Snippets: Sort link:
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
<%= sort_link(@q, :name, "Name", { class: "text-gray-500 hover:text-gray-700" }) %>
</th>
Search field:
<div>
<%= f.label :name_cont, "Name contains", class: "block text-sm font-medium text-gray-700 mb-1" %>
<%= f.search_field :name_cont, class: "w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-emerald-500 focus:border-emerald-500" %>
</div>
Table:
<div class="overflow-x-auto bg-white shadow-md rounded-lg">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
<%= thing.name %>
</td>
Pagination:
<div class="mt-4">
<%= paginate @trunks %>
</div>
- Write tests
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Things', type: :request do
let(:user) { create(:user) }
before do
Warden.test_mode!
sign_in(user)
end
after do
Warden.test_reset!
end
- Following @rspec.mdc check all code with rubocop and rspec. Fix errors if found