Closed postmodern closed 8 months ago
Is there already a route for adding notes?
Ok, its not implemented yet.
Is there a reason why Note
doesn't belongs_to all /db
models ?
@AI-Mozi Note
is supposed to belongs_to
any non-join-models that the user would interact with, such as IPAddress
, HostName
, Service
, URL
, maybe even OpenPort
. I am in the process of adding more new models in the osint
branch of ronin-db-activerecord
, and will have to rebase the branch and update Note
to have more has_many
associations to the new models.
It occurred to me you could DRY up the /db/.../notes
routes by dynamically defining them:
{ip_address: Ronin::DB::IPAddress, ...}.each do |name,model|
post "/db/#{name}/:id/notes" do
@record = model.find(params[:id])
if @record
...
else
...
end
end
delete "/db/#{name}/:id/notes/:note_id" do
@record = model.find(params[:id])
if @record
if @record.notes.destroy(params[:note_id])
...
else
...
end
end
end
end
Implemented by PR #59.
Add a "Add Note" text area and form to all
/db/``show.erb
views to allow adding a new comment to thenotes
association of the record. This may also require adding a_add_note.erb
partial template.