Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Issues
  • #7117

Closed
Open
Created Jun 12, 2014 by Administrator@rootOwner

How to edit a file from projects_controller?

Created by: enter08

I made some changes in the current version of GitLab. When I create a new project, the repo is automatically initialized. A .json is coppied in it at creation. Then I have a new page, like project_name/new_page where I have some form with data (added by project creation).

When I want to edit that data, I want to update my JSON file. HOW? In the update_product of projects_controller I have this: (it works)

::Products::UpdateService.new(@project.product, current_user, params).execute

But I want also to update the .json file with this data.

I tried with this:

file_path = File.join(@path, 'product.json') params[:content] = "test" Files::UpdateService.new(@project, current_user, params, @ref, file_path).execute

I added this line at the begining:

require_relative "../services/files/base_service"

but I thing it still fails to know that @ref and @path is.

I tried with this too:

edit_file_action = Gitlab::Satellite::EditFileAction.new(current_user, @project, @ref, file_path) created_successfully = edit_file_action.commit!( params[:content] = 'test', params[:commit_message] = 'test', params[:encoding] = 'text' )

How to make the correct @ref and @path visible to the projects_controller?

Assignee
Assign to
Time tracking