I have a “Rule list” on “localhost:3000/rules” and its JSON render on “localhost:3000/rules.json”
I want to creat the action “Publish” to upload this json to my FTP but I don’t find the solution to make this with Net:FTP.
Here’s my code :
rules_controller.rb
def publish
require 'net/ftp'
ftp = Net::FTP.new('xxxxxx', 'xxxxxxxx', 'xxxxxxx')
ftp.chdir('www/lol')
ftp.putbinaryfile('rules.json')
ftp.close
end
Thanks in advance
Never worked on this but looking at [ http://stdlib.rubyonrails.org/libdoc/net/ftp/rdoc/classes/Net/FTP.html ] It seems
ftp.loginpart is missing.Well, if you dont need to be authenticated, then need some more insight to give any suggestion. Can you post the problem that you are facing exactly?
Edit:
If you can have your json data (containing all the rules) in a file(like you said
rules.json), thisnet/ftpshould work. Now if you are facing problem with saving the json content in a temporary file, this post – ” File.open, write and save? ” might help. But if you feel that the problem lies completely innet/ftp, then a error log or more detail description of the problem would be helpful.