Home>

-Log in as an administrator user
・ I would like to register packages for general users.
・ Even if you try to have a link with parameters on the new luggage registration page from the search page
-It will be registered in the state of being linked with the logged-in administrator.
admin/baggages_controller.rb

class BaggagesController</pre>
<p><br />
<strong>admin/baggages/index.html.haml</strong></p>
<pre><code>= search_form_for @search, url: admin_baggages_url do | f |
  = f.label: name_cont, "Enter your name"
  = f.search_field: name_cont
  = f.submit "search"
.table
  .thead
    % tr
      % th = sort_link (@search,: name) #result part and link
      % th = sort_link (@search,: address)
  .tbody
    [email protected] users.each do | user | #controller "@users = @ search.result" "returns" what you searched for
      % tr
        -#% td = link_to user.name, new_admin_baggage_url (@q,:'q [user_id_eq]'=>"# {user.id}")
        % td = user.name
        % td = user.address
        % td = link_to "New", new_admin_baggage_url (@q,:'q [user_id_eq]'=>"# {user.id}")


admin/baggages/new.html.haml

.wrapper
  .disply
    = form_for @baggage, url: admin_baggages_path do | f |
      .baggage
        .baggage__box
          % span
            Luggage type
            = f.select: kind, [["Namamono", "Namamono"], ["Chilled", "Chilled"], ["Frozen", "Frozen"], ["Other", "Other" ]], include_blank: "Please select"
        .baggage__box
          % span
            Storage period
            = f.text_field: storage_period, class: "baggage_text", placeholder:'Example) 7'
            % span days
        .baggage__box
          % span
            Tracking number
            = f.text_field: code, class: "baggage_text", placeholder: '123456789012'
      = f.hidden_field: user_id,: value =>@q # (params [: id])
      = f.submit'SEND', class: "baggage__send"