当我尝试创建新的记录图像时,我没有上传,但是当我尝试编辑所有正常工作时。没有错误,创建后我在DB中有nil更新后我有一个图片的链接,一切都很好。我做错了什么?在我使用form_for并且一切正常之前,我将form_for更改为simple_form。也许这里有问题?
控制器:
def create
#byebug
@bar = current_user.bars.new(bar_params)
if @bar.save
UserMailer.admin_verify_email(@bar.id).deliver_now
flash[:success] = t(".bar_created_successfully")
# if admin_verified add bar to the search bos
if @bar.admin_verified
Barsearchsuggestion.index_bar(@bar)
redirect_to bars_path(my_bar: true)
else
redirect_to bar_status_user_path(current_user)
end
else
flash.now[:alert] = @bar.errors.full_messages
render 'users/add_bar'
end
end
def edit
@bar = Bar.find(params[:id])
end
def update
@bar = Bar.find(params[:id])
if @bar.update_attributes(bar_params)
flash[:success] = "Bar updated."
redirect_to bar_status_user_path(current_user)
else
flash.now[:error] = I18n.t("simple_form.error_notification.default_message")
# flash[:error] = @bar.errors.to_array
render 'edit'
end
end
private
def bar_params
params.require(:bar).permit!
end
查看:
=simple_form_for(@bar) do |f|
.form-group
= f.label :profile_picture
= t(".profile_picture_ext_html")
%br
= image_tag f.object.profile_picture.bar_detail.url
= f.file_field :profile_picture, class: 'form-control'
型号:
mount_uploader :profile_picture, BarPictureUploader
答案 0 :(得分:0)
You have to permit the profile_picture
parameter like this:
def bar_params
params.require(:bar).permit(:profile_picture)
end
答案 1 :(得分:0)
尝试在表单中设置RewriteCond %{HTTP_HOST} ^minutos\.com$
RewriteRule ^/?$ "http\:\/\/www\.minutos\.com\/" [R=301,L]