Итак, я пытаюсь отправить свою форму для листинга.Я добавил carrierwave-aws и заставил загрузчик изображений работать в форме, затем, после добавления в форму стилей начальной загрузки, кажется, что отправляется только иногда , а затем в других случаях я нажимаю кнопку отправки и ничего бывает.Нет ошибок в консоли, нет активности на локальном хост-сервере.Один раз это работает, в следующий - кажется, что он зависает / прерывается без активности.
Мой поиск в Google заставил меня подумать, может быть, это как-то связано с турболинками или отсутствующим тегом HTML (я не думаю, что это отсутствиеtag).
Вот мой _form частичный
<div class="card w-75 text-left form-card">
<div class="card-body form-card-body">
<div class="row">
<div class="col-md-6">
<%= form_for @listing, multipart: true do |f| %>
<% if listing.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(listing.errors.count, "error") %> prohibited this listing from being saved:</h2>
<ul>
<% listing.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="form-group">
<%= f.label :name %>
<%= f.text_field :name, placeholder: 'ex. Mission Grove Plaza', class: 'form-control' %>
</div>
<div class="form-group">
<%= f.label :street %>
<%= f.text_field :street, placeholder: 'ex. 140 Main St.', class: 'form-control' %>
</div>
<div class="form-group">
<%= f.label :suite_number %>
<%= f.text_field :suite_number, placeholder: 'ex. Suite 145', class: 'form-control' %>
</div>
<div class="form-group">
<%= f.label :city %>
<%= f.text_field :city, class: 'form-control' %>
</div>
<div class="form-group">
<%= f.label :state %>
<%= f.select :state, ['California'], :prompt => 'Select One', class: 'form-control' %>
</div>
<div class="form-group">
<%= f.label :zipcode %>
<%= f.number_field :zipcode, class: 'form-control' %>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<%= f.label :building_type %>
<%= f.text_field :building_type, placeholder: 'ex. Office, Retail, Industrial', class: 'form-control' %>
</div>
<div class="form-group">
<%= f.label :available_sqft %>
<%= f.number_field :available_sqft, class: 'form-control' %>
</div>
<div class="form-group">
<%= f.label :year_built %>
<%= f.number_field :year_built, class: 'form-control' %>
</div>
<div class="form-group">
<%= f.label :asking_rate %>
<%= f.number_field :asking_rate, class: 'form-control' %>
</div>
<div class="form-group">
<%= f.label :transaction_type %>
<%= f.text_field :transaction_type, placeholder: 'Lease or Sale', class: 'form-control' %>
</div>
<div class="form-group">
<%= f.label :land_size %>
<%= f.number_field :land_size, class: 'form-control' %>
</div>
<div class="form-group">
<%= f.label :market %>
<%= f.text_field :market, placeholder: 'ex. Riverside, Corona, Redlands', class: 'form-control' %>
</div>
<div class="form-group">
Upload main image(s) <%= f.file_field :images, multiple: true, accept: "image/jpeg, image/jpg, image/gif, image/png" %>
<p><em>Please upload all main images at once using shift+click to select all files you want to upload.</em></p>
</div>
<div class="form-group">
Upload thumb image <%= f.file_field :thumb_image %>
<p><em>You can only upload one thumb image.</em></p>
</div>
</div>
</div>
<%= f.submit "Submit", class: 'btn btn-primary' %>
<% end %>
</div>
</div>
вот мой макет / приложение
<!DOCTYPE html>
<html>
<head>
<title><%= @page_title %></title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<meta name="keywords" content="<%= @seo_keywords %>"/>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<%= javascript_include_tag 'https://maps.googleapis.com/maps/api/js?key='+Rails.application.credentials.google_maps_api_key %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= yield(:head_tags) %>
</head>
<body>
<%= render 'shared/nav' %>
<%= yield %>
<%= alerts %>
</body>
</html>
вот мой application.js
//= require rails-ujs
//= require jquery3
//= require jquery-ui
//= require activestorage
//= require cocoon
//= require gritter
//= require bootstrap-sprockets
//= require turbolinks
//= require_tree .
function initMap(lat, lng) {
var myCoords = new google.maps.LatLng(lat, lng);
var mapOptions = {
center: myCoords,
zoom: 13
};
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
var marker = new google.maps.Marker({
position: myCoords,
map: map
});
}
в моем application.scss у меня есть
@import "bootstrap-sprockets";
@import "bootstrap";
и в моем Gemfile у меня есть
gem 'bootstrap-sass', '~> 3.4.0'
gem 'sassc-rails', '>= 2.0.0'
, также здесь мой контроллер листинга
class ListingsController < ApplicationController
before_action :set_listing, only: [:show, :edit, :update, :destroy]
access all: [:show, :index], user: {except: [:destroy, :new, :create, :update, :edit]}, site_admin: :all
def index
search_listings
@page_title = "Mudge Advisor's | Listings"
end
def show
@page_title = @listing.street
@seo_keywords = @listing.set_address
end
def new
@listing = Listing.new
end
def edit
end
def create
@listing = Listing.new(listing_params)
respond_to do |format|
if @listing.save
format.html { redirect_to @listing, notice: 'Listing was successfully created.' }
format.json { render :show, status: :created, location: @listing }
else
format.html { render :new }
format.json { render json: @listing.errors, status: :unprocessable_entity }
end
end
end
def update
respond_to do |format|
if @listing.update(listing_params)
format.html { redirect_to @listing, notice: 'Listing was successfully updated.' }
format.json { render :show, status: :ok, location: @listing }
else
format.html { render :edit }
format.json { render json: @listing.errors, status: :unprocessable_entity }
end
end
end
def destroy
@listing.destroy
respond_to do |format|
format.html { redirect_to listings_url, notice: 'Listing was successfully destroyed.' }
format.json { head :no_content }
end
end
private
def set_listing
@listing = Listing.find(params[:id])
end
def listing_params
params.require(:listing).permit(:name,
:street,
:city,
:state,
:zipcode,
:building_type,
:available_sqft,
:year_built,
:asking_rate,
:land_size,
:market,
{ images: []},
:thumb_image,
:suite_number,
:transaction_type
)
end
def search_listings
if params[:query]
search_words = params[:query]
if !params[:query].empty?
@listings = Listing.kinda_matching(search_words)
else
flash[:notice] = "Search can't be empty"
@listings = Listing.all
end
@listings
else
@listings = Listing.all
end
end
end
and listing model
class Listing < ApplicationRecord
validates :street,
:city,
:state,
:zipcode,
:country,
:building_type,
:asking_rate,
:market,
:transaction_type,
presence: true
validates :street, uniqueness: true
mount_uploader :thumb_image, ListingUploader
mount_uploaders :images, ListingUploader
include PgSearch
pg_search_scope :kinda_matching,
:against => [:name,
:street,
:city,
:state,
:zipcode,
:building_type,
:suite_number,
:transaction_type,
:market
],
:using => {
:tsearch => {:prefix => true}
}
geocoded_by :set_address
after_validation :geocode
def set_address
"#{self.street}, #{self.city}, #{self.state}, #{self.zipcode.to_s}, #{self.country}"
end
end
здесьмой сервер
Started GET "/listings/50/edit" for 127.0.0.1 at 2019-02-05 19:33:57 +0100
Processing by ListingsController#edit as HTML
Parameters: {"id"=>"50"}
Listing Load (2.9ms) SELECT "listings".* FROM "listings" WHERE "listings"."id" = $1 LIMIT $2 [["id", 50], ["LIMIT", 1]]
↳ app/controllers/listings_controller.rb:61
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 13], ["LIMIT", 1]]
↳ app/controllers/concerns/current_user_concern.rb:5
Rendering listings/edit.html.erb within layouts/application
Rendered listings/_form.html.erb (13.8ms)
Rendered listings/edit.html.erb within layouts/application (17.0ms)
Rendered shared/_nav.html.erb (0.5ms)
Completed 200 OK in 246ms (Views: 235.7ms | ActiveRecord: 3.4ms)
Я знаю, что это очень много, и если вы все еще со мной, большое спасибо.Любая помощь будет оценена.