Skip to content

Commit 93fa7d9

Browse files
committed
i think this should work
1 parent 8b6f204 commit 93fa7d9

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

app/controllers/basil_controller.rb

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,27 @@ def about
211211
end
212212

213213
def jam
214-
@recent_commissions = BasilCommission.order('id DESC').limit(16)
214+
@recent_commissions = BasilCommission.order('id DESC').limit(18)
215215
end
216216

217217
def queue_jam_job
218-
raise params.inspect
218+
created_prompt = [
219+
jam_params[:age],
220+
jam_params[:gender],
221+
*jam_params[:features]
222+
].join(', ')
223+
224+
# Create our commission, then redirect back to preview it
225+
BasilCommission.create!(
226+
user: current_user,
227+
entity: nil,
228+
prompt: created_prompt,
229+
job_id: SecureRandom.uuid,
230+
style: ["realistic"].sample,
231+
final_settings: jam_params
232+
)
233+
234+
redirect_back(fallback_location: basil_jam_path, notice: "#{jam_params[:name]} will be visualized shortly. Find them on this page!")
219235
end
220236

221237
def commission_info
@@ -621,4 +637,8 @@ def delete
621637
def commission_params
622638
params.require(:basil_commission).permit(:style, :entity_type, :entity_id, field: {})
623639
end
640+
641+
def jam_params
642+
params.require(:commission).permit(:name, :age, :gender, features: [])
643+
end
624644
end

app/models/basil_commission.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
class BasilCommission < ApplicationRecord
22
acts_as_paranoid
33

4-
belongs_to :user
5-
belongs_to :entity, polymorphic: true
4+
belongs_to :user, optional: true
5+
belongs_to :entity, polymorphic: true, optional: true
66

77
has_one_attached :image,
88
service: :amazon_basil,

0 commit comments

Comments
 (0)