fileupload and backbone.js + Rails - ruby-on-rails-3

I managed to create a small app that uses backbone.js for CRUD process.
Now i am trying to include file upload as well in "Create". i m using "paperclip" to upload image. As i am learning about backbone.js please tell me some approach to making it?

You cannot do this with backbone models. You will have to create a form (including the file field) on the client side and post form to the server.
You can use something like that on the client:
http://www.williambharding.com/blog/rails/rails-ajax-image-uploading-made-simple-with-jquery/

You may want to check out the jquery.iframe.transport plugin. Since you're using rails 3, you can use remotipart instead (it bundles the iframe.transport plugin), which hooks into rails's ujs driver to automatically add support for file upload in ajax requests.

Related

How to generate swagger without writing spec files

I am looking for a gem which will generate swagger doc and showed it on the swagger UI, I came across rswag gem but it requires spec file needs to be present for generating the swagger doc
Is there any gem that will auto generate swagger doc if I put it in on the API controller?
I built an open-source tool to make this easy. Instead of integrating at the code level, the project uses a local proxy to analyze real development traffic and updates your API spec when it observes new behavior in the API. https://github.com/opticdev/optic
For Rails, the only change you have to make is to make the switch from using:
rails server
To starting your API with Optic's start command.
api start
When new API behavior is detected, you can add it to your spec using our UI. Here's an example.

How to upload images with Rails-Api + Vue.js + Cloudinary + Attachinary?

With server rendered rails apps I've always used cloudinary and attachinary to upload images and other files to a third party server and have them linked to my data models.
I am now increasingly using Vue.js with Rails-Api, and I'm wondering if I can still use Attachinary + Cloudinary, and how? What would be the simplest approach?
Cloudinary doesn't support an official Vue.js integration yet. You can try and implement the cloudinary-core package (pure js package) in your project.

How do I create my own API in Yii2?

I want to create API methods which you can access form another platform. Just see the following diagram.
In the above image you can see how to fetch data from Yii2 app using another application, I wanna use same procedure when I going to push data into Yii2 application from the another application. That's means Yii2 just provides api methods to clint to push/pull data.
Give me some suggestion?
Yii2 provides ready to use RESTful Web Service API. http://www.yiiframework.com/doc-2.0/guide-rest-quick-start.html
First of all, you will need separate module for API.
If you use Advanced template (with backend, frontend), you'll need to create api directory in root level of your project. If your project is big, and API will changes in future and your API is for many clients, you should make versioning API. Create directory "modules" in api directory, then create directory "v1" in "modules". In future, if you'll need make a huge changes, create second directory, like "v2".
If you use Basic template, just create modules directory, then create API module.

How can I use PHP files as views in Durandal?

My problem is I want to integrate Durandal witha Wordpress site yet Durandal expects HTML files as views. How can this be changed to use PHP files?
Yes. A php script generates dynamic HTML files on the server. You would just need to generate HTML that is valid within the context of Durandal.
The strategy is similar to using Durandal with ASP.Net, which would be a good place to start looking for tutorials.

Cannot upload image in Rails and Appcelerator

I am developing an iPhone app in Appcelerator Titanium. My app is communicating with an API that I build using Rails 3.
I want to be able to upload an image from the iPhone app to the API (and Amazon S3). I am using the gem called Paperclip. Along with the upload request I need to send the name of the file. But if I do it like below, the image_file_name is not recognized. What is wrong with the call?
In the App: http://pastie.org/1805065
In the API model: http://pastie.org/1805071
In the API controller: http://pastie.org/1805073
Output on the API server: http://pastie.org/1805078
Looks like in the API Controller the line:
#avatar = Avatar.new(params[:avatar])
Should read:
#avatar = Avatar.new(params[:image])
Explanation:
This conclusions was made by looking at the server log output from the API Server, and checking the Parameters hash for the name of the submitted image. Instead of it being named "avatar" as your controller was expecting, it appears to actually be named "image".