Class: Api::V1::ProjectsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/api/v1/projects_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
# File 'app/controllers/api/v1/projects_controller.rb', line 14

def create
  @project = Project.new(params[:project])
  if @project.save
    render :json => {:success => true, :id => @project.id} and return
  else
    render :json => {:success => false, :errors => @project.errors.full_messages.to_sentence} and return
  end
end

#indexObject



4
5
6
7
8
9
10
11
12
# File 'app/controllers/api/v1/projects_controller.rb', line 4

def index
  @bucket = Project.sort_by_name
  @bucket = @bucket.for_client_id(params[:client_id]) unless params[:client_id].blank?
  @bucket = @bucket.where(:git_repo_url => params[:git_repo_url]) unless params[:git_repo_url].blank?
  unless admin?
    @bucket = @bucket.for_user(current_user)
  end
  render :json => @bucket.all
end