Image Not Displaying In Paperclip

This is what i've tried using paperclip

My Model.rb validates_presence_of :book_name, :price, :description, :author

  has_attached_file :avatar, :default_url => "/images/:style/missing.png"   validates_attachment_content_type :avatar, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]

i'm not using styles because it is giving error "Avatar Paperclip::Errors::NotIdentifiedByImageMagickError"

In Index File the tag i'm using. <td><%= image_tag booki.avatar.url(:thumb)%></td>

You have not explained what is not happening that should happen. Do you mean that the thumb does not display? Is the html correct (view the html in the browser).

Colin

Colin Law wrote in post #1171572:

Check out my QUESTION again. ie Is the html correct?

It is always better to ask a specific question within the content of the post. As I type this I cannot see the subject line on screen. I have to scroll up to see it. Also the title says "image not displaying in paperclip". That is ambiguous. It could be that it is displaying the wrong image, or no image at all. Or possibly a run time error is displayed.

Finally, the best way to get help is not to SHOUT at those who are spending their time trying to help.

Absolutely finally, don't forget to answer my question - is the html correct?

Colin

Colin Law wrote in post #1171577:

Check out my QUESTION again. ie Is the html correct?

It is always better to ask a specific question within the content of the post. As I type this I cannot see the subject line on screen. I have to scroll up to see it. Also the title says "image not displaying in paperclip". That is ambiguous. It could be that it is displaying the wrong image, or no image at all. Or possibly a run time error is displayed.

Finally, the best way to get help is not to SHOUT at those who are spending their time trying to help.

Absolutely finally, don't forget to answer my question - is the html correct?

Colin

Yes, and once you said only post those part of code which is incorrect so there's no point in asking about html as m sure about that validation part is incorrect(i have done a lot of google search) when i hit submit then in place of image i'm getting image name like "example image"

I don't understand what you mean by getting that message when you hit submit. I thought the problem with displaying the image. What exactly is the question you are asking? Do you think the upload is failing? I presume you have looked in development.log to see if there were any errors there.

Colin

Colin Law wrote in post #1171580:

Finally, the best way to get help is not to SHOUT at those who are

then in place of image i'm getting image name like "example image"

I don't understand what you mean by getting that message when you hit submit. I thought the problem with displaying the image. What exactly is the question you are asking? Do you think the upload is failing? I presume you have looked in development.log to see if there were any errors there.

Colin

i have made a diff show.html.erb that after i hit submit will redirect me to show file in which i am getting the name of image instead of image. earlier i was getting error or imagemagick but after some google search i found removing styles will do but now i am only getting the name of image(and yea i have checked log file for errors NO ERROR) and i have checked via console too the image is getting stored but not displaying, image is getting stored in public images . .

So, if I understand correctly, you have some erb in the view that should show an image, but in fact it just shows the name. In your situation the first thing I would do is to look at the html to see what html the image_tag is generating. For some reason you don't seem to want to do that.

Colin

Colin Law wrote in post #1171598:

I just cannot understand why you don't want to look at the html. I cannot see how you can move forward without that. It is trivially easy to do.

Colin

Colin Law wrote in post #1171608:

<td><%=image_tag(book.image.url(:medium)) %></td>

tried this is on my frnds system and everything works fine on his system so i'm sure there's nothing wrong in my application but don't know why image is not coming up

I just cannot understand why you don't want to look at the html. I cannot see how you can move forward without that. It is trivially easy to do.

Colin

I just don't know now that how can i make you understand :frowning: "tried this is on my frnds system and everything works fine on his system

By showing us the html that the image tag generates. I am beginning to think that you do not understand what I mean by that.

Colin

Colin Law wrote in post #1171616:

Don't do skype. Just explain why you cannot post the html. Does it even display the page containing your image_tag, is that the problem? If so then post the section of development.log showing the submit and response.

Colin

it's not hard to know generated html you can do it by inspecting element <http://testingfreak.com/inspect-element-in-firefox-chrome-or-ie-browsers&gt;

generated html will be like this :

<img src="http://s3.amazonaws.com/projectsassets/documents/8138/filename.png "> or <img src="/documents/12/filename.png">

<tbody>       <tr>         <td>ABC</td>         <td>123</td>         <td>CBA</td>         <td>DBA</td>

        <td><img src="/images/posts/8-captives-medium.jpg?1428471543" alt="8 captives medium" /></td>         <td><a href="/books/8">Show</a></td>         <td><a href="/books/8/edit">Edit</a></td>         <td><a data-confirm="Are you sure?" rel="nofollow" data-method="delete" href="/books/8">Destroy</a></td>       </tr>   </tbody>

So does that file exist?

Colin

Colin Law wrote in post #1171709:

Exactly which folder is the file 8-captives-medium.jpg stored in? Full path please.

On the view page in the browser do you see "8 captives medium" where the image should be?

Post the bit of development.log showing the request for the view page please.

Please answer all three questions to save me asking again. Thanks.

Colin

Colin Law wrote in post #1171724:

Exactly which folder is the file 8-captives-medium.jpg stored in? Full path please.

On the view page in the browser do you see "8 captives medium" where the image should be?

Post the bit of development.log showing the request for the view page please.

Please answer all three questions to save me asking again. Thanks.

Colin

Answer 1:- app/public/images/posts/images.jpg

Answer 2:- http:// prntscr.com /6rgtxn (Remove Spaces)

Answer 3:- Started GET "/books/new" for 127.0.0.1 at 2015-04-07 11:51:02 +0530   [1m[36mActiveRecord::SchemaMigration Load (0.2ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m Processing by BooksController#new as HTML Completed 500 Internal Server Error in 38ms (ActiveRecord: 0.7ms)

NoMethodError (undefined method `validation_presence_of' for #<Class:0xa478d1c>):   app/models/book.rb:2:in `<class:Book>'   app/models/book.rb:1:in `<top (required)>'   app/controllers/books_controller.rb:17:in `new'

  Rendered /home/amit/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (14.6ms)