Class: CodersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- CodersController
- Defined in:
- app/controllers/coders_controller.rb
Instance Method Summary (collapse)
-
- (Object) index
returns coders in json based upon certain paramters.
- - (Object) projects
Methods inherited from ApplicationController
Instance Method Details
- (Object) index
returns coders in json based upon certain paramters
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/coders_controller.rb', line 24 def index conditions(Coder) if params[:org_login] org = Org.where(:name => params[:organization]).first end if params[:project_name] project = Project.where(:name => params[:project_name]).first end @conditions << "commits.org_id = '#{org.id}'" unless org.nil? @conditions << "commits.project_id = '#{project.id}'" unless project.nil? @coders = Coder.includes(:commits).where(@conditions.join(" and ")) @items = [:results => @coders.size, :page => (params[:page].nil? ? 1 : params[:page]), :total_items => @coders.size] respond_to do |format| format.json { render :json => [@items, @coders].to_json} format.html end end |
- (Object) projects
49 50 51 52 53 54 55 |
# File 'app/controllers/coders_controller.rb', line 49 def projects @coder = Coder.where(:login => params[:login]).first respond_to do |format| format.json { render :json => [@coder, :projects => [@coder.projects]].to_json} end end |