Class: SoundsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- SoundsController
- Defined in:
- app/controllers/sounds_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
-
#api_index ⇒ Object
GET /api/v1/sounds.
- #api_show ⇒ Object
- #autocomplete ⇒ Object
-
#create ⇒ Object
POST /sounds or /sounds.json.
-
#destroy ⇒ Object
DELETE /sounds/1 or /sounds/1.json.
-
#edit ⇒ Object
GET /sounds/1/edit.
-
#index ⇒ Object
GET /sounds or /sounds.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /sounds/new.
- #select_options ⇒ Object
-
#set_sound ⇒ Object
private
Use callbacks to share common setup or constraints between actions.
-
#show ⇒ Object
GET /sounds/1 or /sounds/1.json.
-
#sound_params ⇒ Object
private
Only allow a list of trusted parameters through.
-
#update ⇒ Object
PATCH/PUT /sounds/1 or /sounds/1.json.
Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration
Methods included from RedirectHelper
Methods included from RequestType
Methods included from LogRecent
Methods included from Cookies
#digest_cookie, #digested_cookie_exists?
Methods included from Whitelist
Methods included from ProjectsHelper
#cumulative_gb_per_year, #cumulative_projects_created_per_year, #document_cumulative_gb_per_year, #document_gb_per_year, #gb_per_year, #image_cumulative_gb_per_year, #image_gb_per_year, #invalid_object, #project_classification, #project_initials, #project_link, #project_login_link, #project_matches, #project_tag, #projects_list, #projects_search_form, #sound_cumulative_gb_per_year, #sound_gb_per_year, #taxonworks_classification, #week_in_review_graphs
Methods included from Api::Intercept
Methods included from TokenAuthentication
#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate
Instance Method Details
#api_index ⇒ Object
GET /api/v1/sounds
24 25 26 27 28 29 |
# File 'app/controllers/sounds_controller.rb', line 24 def api_index @sounds = Queries::Sound::Filter.new(params.merge!(api: true)).all .where(project_id: sessions_current_project_id) .page(params[:page]).per(params[:per]) render '/sounds/api/v1/index' end |
#api_show ⇒ Object
35 36 37 |
# File 'app/controllers/sounds_controller.rb', line 35 def api_show render template: '/sounds/api/v1/show' end |
#autocomplete ⇒ Object
103 104 105 106 107 |
# File 'app/controllers/sounds_controller.rb', line 103 def autocomplete @sounds = Queries::Sound::Autocomplete.new( params[:term], project_id: sessions_current_project_id ).autocomplete end |
#create ⇒ Object
POST /sounds or /sounds.json
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/sounds_controller.rb', line 49 def create @sound = Sound.new(sound_params) respond_to do |format| if @sound.save format.html { redirect_to @sound, notice: 'Sound was successfully created.' } format.json { render :show, status: :created, location: @sound } else format.html { render :new, status: :unprocessable_content } format.json { render json: @sound.errors, status: :unprocessable_content } end end end |
#destroy ⇒ Object
DELETE /sounds/1 or /sounds/1.json
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/controllers/sounds_controller.rb', line 77 def destroy if @sound.destroy respond_to do |format| format.html { redirect_to sounds_path, status: :see_other, notice: 'Sound was successfully destroyed.' } format.json { head :no_content } end else respond_to do |format| format.html { redirect_to sounds_path, notice: @sound.errors..join('. ') } format.json { head :no_content, status: :unprocessable_content } end end end |
#edit ⇒ Object
GET /sounds/1/edit
45 46 |
# File 'app/controllers/sounds_controller.rb', line 45 def edit end |
#index ⇒ Object
GET /sounds or /sounds.json
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/sounds_controller.rb', line 9 def index respond_to do |format| format.html do @recent_objects = Sound.where(project_id: sessions_current_project_id).order(updated_at: :desc).limit(10) render '/shared/data/all/index' end format.json { @sounds = Queries::Sound::Filter.new(params).all .where(project_id: sessions_current_project_id) .page(params[:page]).per(params[:per]) } end end |
#list ⇒ Object
99 100 101 |
# File 'app/controllers/sounds_controller.rb', line 99 def list @sounds = Sound.where(project_id: sessions_current_project_id).page(params[:page]).per(params[:per]) end |
#new ⇒ Object
GET /sounds/new
40 41 42 |
# File 'app/controllers/sounds_controller.rb', line 40 def new @sound = Sound.new end |
#select_options ⇒ Object
91 92 93 94 95 96 |
# File 'app/controllers/sounds_controller.rb', line 91 def @sounds = Sound.select_optimized( sessions_current_user_id, sessions_current_project_id, params[:target]) end |
#set_sound ⇒ Object (private)
Use callbacks to share common setup or constraints between actions.
111 112 113 |
# File 'app/controllers/sounds_controller.rb', line 111 def set_sound @sound = Sound.find(params[:id]) end |
#show ⇒ Object
GET /sounds/1 or /sounds/1.json
32 33 |
# File 'app/controllers/sounds_controller.rb', line 32 def show end |
#sound_params ⇒ Object (private)
Only allow a list of trusted parameters through.
116 117 118 |
# File 'app/controllers/sounds_controller.rb', line 116 def sound_params params.require(:sound).permit(:name, :sound_file) end |
#update ⇒ Object
PATCH/PUT /sounds/1 or /sounds/1.json
64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/controllers/sounds_controller.rb', line 64 def update respond_to do |format| if @sound.update(sound_params) format.html { redirect_to @sound, notice: 'Sound was successfully updated.' } format.json { render :show, status: :ok, location: @sound } else format.html { render :edit, status: :unprocessable_content } format.json { render json: @sound.errors, status: :unprocessable_content } end end end |