In my view there is a query like this ..
<%= CaricatureType.find_by(id: StudioOrder.find_by(user_id: spree_current_user.id).style_id).name %>
The schema for studio_orders and caricature_types is as follows
create_table "studio_orders", force: :cascade do |t|
t.integer "user_id"
t.integer "occasion_id"
t.integer "style_id"
t.integer "number_of_people"
t.string "artwork_size"
t.integer "package_id"
t.text "instructions"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.float "initial_price"
t.float "final_price"
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.json "avatars"
t.integer "address_id"
end
create_table "caricature_types", force: :cascade do |t|
t.string "name"
t.text "description"
t.float "price"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
Now the question is, the query in the view I have posted above comes in order_summary screen, and the query simply outputs the name of the style he has choosen. Now the thing is, technically there can be many rows in the studio_orders with the same user id. But how to display the current style the user has choosen in the order_summary screen.