This question seems simple at first glance, but has slowed down my work! Please, help me to figure out where am I making a mistake.
I would like to build a server using Ruby-on-Rails which will have one main function: to serve a post requests with some data from my client side JS. Then use jquery’s Ajax method to send asynchronous requests:
function processPeople() {
SOME.api(".get", {owner_id:frnds.response[i].uid,count:"3"}, function(posts) {
var usefulPosts = posts.response;
for (var i = 1; i <= 2; i++) {
$.ajax({
type: 'POST',
url: 'wallposts',
data: {uid: usefulPosts[i]["from_id"], uniqpost_id: usefulPosts[i]["id"], tent:usefulPosts[i]["text"]}
});
};
});
i++;
if (i<2) {
setTimeout(processPeople, 1000);
}
}
and here my controller where post requests are sent:
def create
# debugger
if !(Wallpost.from_user(params[:uid]).find_by_uniqpost_id(params[:uniqpost_id]))
@newWP = Wallpost.new(:uid => params[:uid], :content => params[:content],
:uniqpost_id => params[:uniqpost_id])
@newWP.save
end
What if I want just to save data on server side and NOTHING more, what would I do on server side? Every time I try to post info to my sever it answers me with 500-error:
ActionView::MissingTemplate (Missing template wallposts/create, application/create with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :handlers=>[:erb, :builder, :coffee]}. Searched in:
* "/home/yurgen/rails_project/vkraigslist/app/views"
You need to specify the return of the controller. HTTP protocol requests that.
If you don’t want to return any code, simply put a
in the end of your controller.