Add Image to a table Ruby on Rails - ruby-on-rails-3

I'm a RoR beginner and I can't seem to find a tutorial on the following thing:
I want to add a picture for each of the tv shows in my database and then want to display the image by calling #show.image in my view (show being a tv show).
First, what's the column content ? (I would assume a string, but I'm thinking there might be something more appropriate)
Second, is there a way that I won't need to add URL's manually to the DB ? Like if I could somehow specify that the image name is the same as the tv show's name ?
My questions might be a bit confusing so please let me know if you cant understand what I mean!
Cheers

You need to use a gem called paperclip, it is very good.
Here is a link to the railscast
The railscast is pretty old, so the paperclip is a plugin, which won't work with rails 3.2 + .
The below github link will be of better use
Also the gem is open source and you can see this on github

For the first part of your question, I'm assuming that you want to store the URL's of the images in the database, and not the images themselves. string is a fine column type to use for this.
On the second part - yes, you can generate the image filename from other data if you want to. Probably the best way to do this is in the model, maybe with something like this:
def image
"/images/#{self.name}.png"
end
Then in your view, you can just call #show.image in the template.

Related

Show recently added record at top in vuejs

There is a image upload functionality in my vuejs application.
The image upload works good and the uploaded recorded is also displayed.
But this recently added record get displayed at last in my list. On page refresh it appears at top.
I want to show the recently uploaded image at top as soon as after successful upload.
I have been trying really hard for this since 2 days and couldn't find the solution.
Please help. Vuejs version is 2
basically if I'm correct what you want is to push new images to the images array, for this just use unshift()
something like this
this.images.unshift('url_or_info_of_the_new_image')
Here, you do have an example of code showing you how you could achieve this.
https://codesandbox.io/s/gracious-tree-nig54?file=/src/App.vue
Essentially, the most interesting part is this.initialArray = [this.newValue, ...this.initialArray].
Also, depends on what you've tried until now but keep in mind the few caveats JavaScript does have with VueJS v2: https://v2.vuejs.org/v2/guide/reactivity.html#For-Arrays

Imgur API v3 - Retrieve Image/Album comments

I'm developing a Windows Phone unofficial client for Imgur, the documentation talks about Comments endpoints/data models...but there isn't any method to retrieve comments about a specific image or album.
Anyone known how to retrive them...if is possible? Thanks
After a month I understand how to retrieve them: just putting "/comments" after album or image id. Stupid incomplete API documentation.
To clarify I want to add few things:
Indeed You need to put '/comments', so in the end Your url should look like:
https://api.imgur.com/3/gallery/cUkfS9L/comments/best.
The id ('cUkfS9L' here) may be the id of IMAGE, not only gallery.
But what's more important, and where I had a problem:
It looks like this doesn't work for newest images.
I tried it for a list of newest images (got by '(...)time/all(...)' sorting in query) and noticed that getting comments works for like 4th page of my images.
My solution was changing "time/all" to "top". Now I had much older images and getting comments worked well for them.

Ideas of display data like most social network apps

I want to display data like most social network apps use now. They use a lot of separated frames. In each frame it has texts, pictures, buttons and something else. I absolutely don't know how to do this. I think I can use table view and use grouped style (remove group name label) to display it but I don't know whether I can put button on it and whether it is the smartest way to fix my problem.
Can you explain clearly for me or just give me tutorial, links or something related to it?
An experience shared by a Facebook developer on how they built the iOS app.
https://www.facebook.com/notes/facebook-engineering/under-the-hood-rebuilding-facebook-for-ios/10151036091753920

Rails - creating a system for drag-and-drop download

This is a problem I'm trying to think about how to approach -- I haven't actually started it yet.
What I want to do is create a system where there is a gallery of images. These images can be dropped into a folder or some icon in one part of the screen. Then, the images that have been placed in this folder should be able to be downloaded as a zip.
I was intending to use jQuery to do the drag and drop, probably with some AJAX to accomplish the rest of the stuff, but I'm really just not sure how I would accomplish doing this, or if it's even possible (like if the web application can compress the folder of images).
Also, I'd be programming in Rails 3.
Any ideas?
Sounds like a neat interface. I think jQuery drag and drop is the way to go. Once an image is dropped, trigger an AJAX request GET '/photos/download/#{photo_id}'. This action could then utilize Rails send_file, http://apidock.com/rails/ActionController/Streaming/send_file.
def download
#photo = Photo.find(params[:id])
send_file #photo.image
end

Displaying image on Scroll View

I am developing an iPhone application where i want to display three image in each row on scroll view where i need to click action on each image like Photo album in iPhone. I am not getting any sample code.
Hoping for help
subodh
There's plenty of sample code out there, I found this after only basic googling. You want to search for "UIImageView Iphone". It's also worth mentioning that Apple's very own Developer Center is extremely well written, and will teach you everything you need to know about iPhone programming.
Generally it is frowned down upon to say to look more or read documentation, but you really haven't looked at all. Especially because of Apple's own resource that tells you how to do almost anything, especially something like this. It's not something you can pick up and bits and pieces of and expect to be successful with, it really should be learned starting from the beginning and moving forward. This is especially true if you've never programmed before or are unfamiliar with C/Objective-C.
Three20 has a photo browser that is open source and works similarly to the iPhone's photo browser with some nice code examples. The images come from an image source object that can relate them to images in your apps bundle or images on the web. Looks like its Google group is here. I think that to use images in your bundle you use a URL formed like: bundle://image-name.png and not the typical use of the main bundle to get a path to resource.