Sha256: 8fd68b3d31fe36e94edb2c5722580053229506fa860178bf622e40b8aa7d0473

Contents?: true

Size: 885 Bytes

Versions: 14

Compression:

Stored size: 885 Bytes

Contents

class C2::Informant::EntriesController < C2::BaseController
  respond_to(:json)
  before_filter :load_source
  
  def index
    @entries = @source.entries.offset(0).limit(12)
    render :json => @source.entries_as_json(@entries)
  end
  
  def show
    @entry = @source.entries.find(params[:id])
    render :json => @source.entry_as_json(@entry)
  end
  
  def create
    @entry = @source.klass.new(@source.sanitized(params))
    @entry.save
    render :json => @source.entry_as_json(@entry)
  end

  def update
    @entry = @source.entries.find(params[:id])
    @entry.update_attributes(@source.sanitized(params))
    render :json => @source.entry_as_json(@entry)
  end
  
protected
  
  def load_source
    @locus = C2::Informant::Locus.find(params[:locus_id])
    @bucket = @locus.buckets.find(params[:bucket_id]) if params[:bucket_id]
    @source = (@bucket || @locus)
  end  
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
c2-0.1.13 app/controllers/c2/informant/entries_controller.rb
c2-0.1.12 app/controllers/c2/informant/entries_controller.rb
c2-0.1.11 app/controllers/c2/informant/entries_controller.rb
c2-0.1.10 app/controllers/c2/informant/entries_controller.rb
c2-0.1.9 app/controllers/c2/informant/entries_controller.rb
c2-0.1.8 app/controllers/c2/informant/entries_controller.rb
c2-0.1.7 app/controllers/c2/informant/entries_controller.rb
c2-0.1.6 app/controllers/c2/informant/entries_controller.rb
c2-0.1.5 app/controllers/c2/informant/entries_controller.rb
c2-0.1.4 app/controllers/c2/informant/entries_controller.rb
c2-0.1.3 app/controllers/c2/informant/entries_controller.rb
c2-0.1.2 app/controllers/c2/informant/entries_controller.rb
c2-0.1.1 app/controllers/c2/informant/entries_controller.rb
c2-0.1.0 app/controllers/c2/informant/entries_controller.rb