Image Not Displaying In Paperclip

95 views
Skip to first unread message

Edward Maya

unread,
Apr 7, 2015, 4:53:34 AM4/7/15
to rubyonra...@googlegroups.com
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>

--
Posted via http://www.ruby-forum.com/.

Colin Law

unread,
Apr 7, 2015, 5:56:26 AM4/7/15
to rubyonra...@googlegroups.com
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

Edward Maya

unread,
Apr 7, 2015, 6:08:53 AM4/7/15
to rubyonra...@googlegroups.com
Colin Law wrote in post #1171572:
Check Out My Post TITLE Again.

Colin Law

unread,
Apr 7, 2015, 6:44:48 AM4/7/15
to rubyonra...@googlegroups.com
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

Edward Maya

unread,
Apr 7, 2015, 6:53:58 AM4/7/15
to rubyonra...@googlegroups.com
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"

Colin Law

unread,
Apr 7, 2015, 7:01:07 AM4/7/15
to rubyonra...@googlegroups.com
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

Edward Maya

unread,
Apr 7, 2015, 7:42:04 AM4/7/15
to rubyonra...@googlegroups.com
Colin Law wrote in post #1171580:
> On 7 April 2015 at 11:53, Edward Maya <li...@ruby-forum.com> wrote:
>>> 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 . .

Colin Law

unread,
Apr 7, 2015, 8:26:21 AM4/7/15
to rubyonra...@googlegroups.com
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

Edward Maya

unread,
Apr 7, 2015, 8:49:28 AM4/7/15
to rubyonra...@googlegroups.com
Colin Law wrote in post #1171598:
<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

Colin Law

unread,
Apr 7, 2015, 8:52:48 AM4/7/15
to rubyonra...@googlegroups.com
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

Edward Maya

unread,
Apr 7, 2015, 9:00:39 AM4/7/15
to rubyonra...@googlegroups.com
Colin Law wrote in post #1171608:
I just don't know now that how can i make you understand :(
"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"

Colin Law

unread,
Apr 7, 2015, 9:08:13 AM4/7/15
to rubyonra...@googlegroups.com
On 7 April 2015 at 13:59, Edward Maya <li...@ruby-forum.com> wrote:
> Colin Law wrote in post #1171608:
>> On 7 April 2015 at 13:49, Edward Maya <li...@ruby-forum.com> wrote:
>>> <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 :(

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

Edward Maya

unread,
Apr 7, 2015, 9:27:43 AM4/7/15
to rubyonra...@googlegroups.com
Colin Law wrote in post #1171616:
Do you have just 2 minutes to come over skype ?
silent_assassinoo7

Colin Law

unread,
Apr 7, 2015, 11:30:30 AM4/7/15
to rubyonra...@googlegroups.com
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

Nugi Nugraha

unread,
Apr 7, 2015, 9:08:40 PM4/7/15
to rubyonra...@googlegroups.com
silent_assassinoo7'

it's not hard to know generated html
you can do it by inspecting element

generated html will be like this :
or
<img src="/documents/12/filename.png">



--
Mou Dareka no, tame janakutte
Jibun no Tame ni Warette Iru

( Aqua Timez - Alones )

Edward Maya

unread,
Apr 8, 2015, 1:41:54 AM4/8/15
to rubyonra...@googlegroups.com
<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>

Colin Law

unread,
Apr 8, 2015, 4:08:23 AM4/8/15
to rubyonra...@googlegroups.com
On 8 April 2015 at 06:41, Edward Maya <li...@ruby-forum.com> wrote:
> <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>

So does that file exist?

Colin

Edward Maya

unread,
Apr 8, 2015, 6:30:32 AM4/8/15
to rubyonra...@googlegroups.com
Colin Law wrote in post #1171709:
Yes and is also getting stored in images folder

Colin Law

unread,
Apr 8, 2015, 9:01:07 AM4/8/15
to rubyonra...@googlegroups.com
On 8 April 2015 at 11:30, Edward Maya <li...@ruby-forum.com> wrote:
> Colin Law wrote in post #1171709:
>> On 8 April 2015 at 06:41, Edward Maya <li...@ruby-forum.com> wrote:
>>> <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>
>>
>> So does that file exist?
>>
>> Colin
>
> Yes and is also getting stored in images folder

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

Edward Maya

unread,
Apr 9, 2015, 1:07:17 AM4/9/15
to rubyonra...@googlegroups.com
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)

Colin Law

unread,
Apr 9, 2015, 3:10:33 AM4/9/15
to rubyonra...@googlegroups.com
See comments inserted below

On 9 April 2015 at 06:06, Edward Maya <li...@ruby-forum.com> wrote:
> 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



If you had inserted your comment immediately below my question it
would have saved you typing.
So when I asked "does that file exist" meaning 8-captives-medium.jpg
and you said yes, then actually meant you meant there is a file called
images.jpg but not one of the expected name.

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


"Yes" would have done

>
> 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'


So when you said "and yea i have checked log file for errors NO ERROR"
then that was not entirely correct.


>
>
> Rendered
> /home/amit/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_source.erb


And that shows the html that you posted containing the image tag?
Unlikely I think.

No time at the moment, will look again later.

Colin

Colin Law

unread,
Apr 9, 2015, 3:54:56 PM4/9/15
to rubyonra...@googlegroups.com
On 9 April 2015 at 08:09, Colin Law <cla...@gmail.com> wrote:
> On 9 April 2015 at 06:06, Edward Maya <li...@ruby-forum.com> wrote:

>> NoMethodError (undefined method `validation_presence_of' for
>> #<Class:0xa478d1c>):
>> app/models/book.rb:2:in `<class:Book>'

Look at the line pointed to carefully and consider whether what is
there is exactly what was intended. Compare it carefully with other
examples showing similar code. When writing software, to coin a
phrase, the devil is in the detail.

Any comments on the points I made in my last post?

Colin

Edward Maya

unread,
Apr 10, 2015, 2:54:02 AM4/10/15
to rubyonra...@googlegroups.com
Colin Law wrote in post #1171817:
And that is what exactly i asked for in the beginning. i did said that
same program working on my frnds pc with no error but errors showing up
in validation, can i get a proper validation code ?

Colin Law

unread,
Apr 10, 2015, 4:16:31 AM4/10/15
to rubyonra...@googlegroups.com
As I said:

>> Look at the line pointed to carefully and consider whether what is
>> there is exactly what was intended. Compare it carefully with other
>> examples showing similar code. When writing software, to coin a
>> phrase, the devil is in the detail.

Try looking for documentation for validation_presence_of for example.
I doubt if you will find any. If you manage to progress in the art of
writing software you will eventually realise the truth of my statement
- the devil is in the detail.

As or that code working on another PC I think that is unlikely.

Colin

Colin Law

unread,
Apr 10, 2015, 4:12:30 PM4/10/15
to rubyonra...@googlegroups.com
On 10 April 2015 at 09:15, Colin Law <cla...@gmail.com> wrote:
> ..
> As or that code working on another PC I think that is unlikely.

That should have read 'as for that code working' of course. I got the
detail wrong myself that time.

Colin
Reply all
Reply to author
Forward
0 new messages