Home undefined method `image' for #<Post:0x007f6018a697b0>
Reply: 0

undefined method `image' for #<Post:0x007f6018a697b0>

user6419
1#
user6419 Published in September 19, 2018, 9:12 am

I get this error in my porject :

undefined method `image' for #

this is my code : 
= simple_form_for @post do |f|
  = f.input :image
  = f.input :caption
  = f.button :submit

this is my model post.rb

class Post < ApplicationRecord
    class Post < ActiveRecord::Base
        validates :image, presence: true

        has_attached_file :image, styles: { :medium => "640x" }
        validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
    end
end

this is my controller post_controller.rb

class PostsController < ApplicationController
    def index
    end

    def new
        @post = Post.new
    end
end
share|improve this question
  • Can you please add the schema.rb part related to posts? – khaled_gomaa Apr 13 at 11:27
  • class Post < ApplicationRecord; class Post < ActiveRecord::Base -- What's going on here??!!! That looks definitely wrong to me. – Tom Lord Apr 13 at 12:23

1 Answer 1

active oldest votes
up vote 1 down vote
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.531227 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO