So with the devise gem set up I have, my users can register as either a buyer account or a seller account. If they're buyers, they can make nested inquiries for information to buy from sellers. On the sellers index page, if I am a buyer and logged in as the current user, I want every inquiry that I've made to be displayed on a part of the page with the title of each inquiry displayed next to a radio button or as an option from a pull down menu for the buyer to select from, along with the inquiry ID hidden so I can use it in action mailer after I select it. I am guessing I need a form with a post request to select the inquiry I've done for the next step, so this is what I've been trying so far:
<%= simple_form_for [@buyer, @inquiries], method: :post do |f| %>
<%= f.input :inquiry.name, collection: @inquiries, as: :radio_buttons %>
<%= f.text_field :inquiry_id, value: inquiry.id, type: "hidden" %>
<%= f.submit 'New user' %>
In my sellers index controller, for the buyer and inquiry I have
@buyer = current_user.buyer if current_user.buyer
@inquiries = @buyer.inquiries if current_user.buyer
However, I haven't been able to properly get my list of inquiries to show with a hidden ID either as a pull down menu of options or radio button options.
Afterwards, on the same seller index page, I have checkboxes on every individual seller partial card. As a buyer, I want to be able to use action mailer to send every seller whose checkbox I clicked on an email inviting them to see a link to the show page of the inquiry that I've picked, all with the click of a button. I haven't gotten close to getting this to work. So far the checkbox I have on each seller partial so I can have their ID's hidden is this:
<%= check_box("seller", "id", {}, seller.id) %>
This is my inquiry mailer file:
class InquiryMailer < ApplicationMailer
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.inquiry_mailer.invite.subject
#
def invite(seller)
# @greeting = "Hi"
@buyer = current_user.buyer
@inquiries = @buyer.inquiries
@seller = seller
mail(to: @seller.email, subject: 'You have been invited to sell your!')
end
end
And this is my invite.html.erb file:
<p>Hello, <%= @seller.email %>!</p>
<p>You have been invited to sell to <%=@buyer.name%>!</p>
<p>Their inquiry is titled <%= @inquiry.title %>, it can be found at<p>
<p><%= link_to 'See this inquiry!', buyer_inquiry_path(@buyer, @inquiry) %><p>
But I'm not sure if what I have so far is right and where to go from here to get my next steps to work. I do not know how to transmit the inquiry ID to action mailer, nor do I know how to send the selected checkboxes properly either. I'd be grateful for any advice on what steps I should take next to get my inquiries to show the proper way and how to send the inquiry that I pick to the sellers that I pick. Thank you!
Aucun commentaire:
Enregistrer un commentaire