Ich benutze Büroklammer Edelstein, um Bilder hochzuladen, aber diese Bilder werden nicht im Öffentlichen Ordner oder sonstwo gespeichert, stattdessen zeigt es missing.png. Ich habe bereits URL, Pfad angegeben.Büroklammerbild speichert nirgendwo (missing.png) Schienen
Modell - Dies ist das Modell mit Büroklammer konfiguriert
class AudiModel < ActiveRecord::Base
has_attached_file :exterior_image,
:path => ":rails_root/public/system/:attachment/:id/:style/:filename",
:url => "/system/:attachment/:id/:style/:filename",
:styles => { :medium => "300x300>", :thumb => "100x100>" }
validates_attachment_content_type :exterior_image, content_type: /\Aimage\/.*\Z/
end
Contoller
class AudiModelsController < ApplicationController
before_action :set_audi_model, only: [:show, :edit, :update, :destroy]
# GET /audi_models
# GET /audi_models.json
def index
@audi_models = AudiModel.all
end
# GET /audi_models/1
# GET /audi_models/1.json
def show
end
# GET /audi_models/new
def new
@audi_model = AudiModel.new
end
# GET /audi_models/1/edit
def edit
end
# POST /audi_models
# POST /audi_models.json
def create
@audi_model = AudiModel.new(audi_model_params)
respond_to do |format|
if @audi_model.save
format.html { redirect_to @audi_model, notice: 'Audi model was successfully created.' }
format.json { render :show, status: :created, location: @audi_model }
else
format.html { render :new }
format.json { render json: @audi_model.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /audi_models/1
# PATCH/PUT /audi_models/1.json
def update
respond_to do |format|
if @audi_model.update(audi_model_params)
format.html { redirect_to @audi_model, notice: 'Audi model was successfully updated.' }
format.json { render :show, status: :ok, location: @audi_model }
else
format.html { render :edit }
format.json { render json: @audi_model.errors, status: :unprocessable_entity }
end
end
end
# DELETE /audi_models/1
# DELETE /audi_models/1.json
def destroy
@audi_model.destroy
respond_to do |format|
format.html { redirect_to audi_models_url, notice: 'Audi model was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_audi_model
@audi_model = AudiModel.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def audi_model_params
params.require(:audi_model).permit(:car_model, :variant, :introduction, :engine, :exterior_image, :video, :brochure)
end
end
Können Sie den entsprechenden Controller-Code zeigen und welche Version von Schienen Sie verwenden? – dp7
Rails-Version ist 4.2.5 und höher ist mein Controller-Code. Ich habe es mit dem Befehl scaffold erzeugt. – Ekta