Parsing data from a form to a gems method?

Hi,.

I’m trying to parse a users commit message to the inbuilt grit grit
method ‘repo.commit_all’.

The trouble is I can’t figure out how to do it. The code below runs
without throwing exceptions, but when I look in the git log my files
have not been committed. They have however been uploaded successfully to
the directory.

I’m pretty new to this, so any help, advice or pointers to good grit
tutorials would be great

Code that does not commit the files:
class UploadController < ApplicationController
require ‘grit’
include Grit

def index
#Renders a fiew for the user.
render ‘upload.rhtml’
end
def create
repo =
Grit::Repo.new("/home/resource_portal/website/public/data/upload")
#posts to the data model.
post = DataFile.save(params[:upload])
puts “file uploaded”
render ‘upload’
post = repo.commit_all(params[:message])
end
end

Code that commits the files but does not add the users commit message:
class UploadController < ApplicationController
require ‘grit’
include Grit

def index
#Renders a fiew for the user.
render ‘upload.rhtml’
end
def create
repo =
Grit::Repo.new("/home/resource_portal/website/public/data/upload")
#posts to the data model.
post = DataFile.save(params[:upload])
puts “file uploaded”
render ‘upload’
repo.commit_all(:message)
end
end

Well in the second example you have

repo.commit_all(:message)

which I suspect should be

repo.commit_all(params[:message])

Hi,
Have added params[:message]) as suggested, but the files still arn’t
being committed to the git repo. They do get committed when I just parse
(:message)to the repo.commit_all method. The files are also still being
uploaded to the directory. Any further ideas?

Thanks in advance,
Jen.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs