Я пытаюсь добавить мое приложение 'carrierwave' gem.I создать класс image_uploaderСамовольная параметры: image.Carrierwave
class ImageUploader < CarrierWave::Uploader::Base
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
и создать модель photo.rb
class Photo < ActiveRecord::Base
mount_uploader :image, ImageUploader
belongs_to :photoable, polymorphic: true
belongs_to :post
end
и photo.rb имеет полиморфную связь с post.rb
class Post < ActiveRecord::Base
has_many :comments
has_many :post_attachments
validates :title, :body, presence: true
has_many :photos, as: :photoable
accepts_nested_attributes_for :photos
end
post.rb имеет вложенные атрибуты из photo.rb
params.require(:post).permit(:title, :body, photo_attributes: [:image])
и это является частичным _form.html.haml от post.rb модели
= form_for [:admin, @post] do |f|
= f.file_field :image
= f.text_field :title, class: "form-control", placeholder: "Title"
= f.text_area :body, rows: 12, class: "form-control", placeholder: "Message"
.pull-right
= f.submit "Send", class: "btn btn-success"
но когда я создаю сообщение с изображением, оболочка покажу мне ошибка
Unpermitted parameters: image
как исправить?
извините за мой плохой английский
UPD
schema.rb
create_table "photos", force: true do |t|
t.datetime "created_at"
t.datetime "updated_at"
t.string "image"
t.integer "photoable_id"
t.string "photoable_type"
end
create_table "posts", force: true do |t|
t.string "title"
t.text "body"
t.datetime "created_at"
t.datetime "updated_at"
end
решаемые
спасибо за ответ, но это решение не work.Сause где-то еще – vveare138