Class: Storytime::Dashboard::SnippetsController
Instance Method Summary
collapse
#authenticate_user!, #current_user, #setup, #user_signed_in?
#current_storytime_site
#content_for, #content_for?, #view_context
Instance Method Details
#create ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/storytime/dashboard/snippets_controller.rb', line 29
def create
@snippet = Storytime::Snippet.new(snippet_params)
authorize @snippet
respond_with @snippet do |format|
if @snippet.save
format.json { render :index }
else
format.json { render :new, status: :unprocessable_entity }
end
end
end
|
#destroy ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'app/controllers/storytime/dashboard/snippets_controller.rb', line 54
def destroy
authorize @snippet
@snippet.destroy
flash[:notice] = I18n.t('flash.snippets.destroy.success') unless request.xhr?
respond_with [:dashboard, @snippet] do |format|
format.html{ redirect_to url_for([:dashboard, Storytime::Snippet]) }
end
end
|
#edit ⇒ Object
24
25
26
27
|
# File 'app/controllers/storytime/dashboard/snippets_controller.rb', line 24
def edit
authorize @snippet
respond_with @snippet
end
|
#index ⇒ Object
13
14
15
16
|
# File 'app/controllers/storytime/dashboard/snippets_controller.rb', line 13
def index
authorize @snippets
respond_with @snippets
end
|
#new ⇒ Object
18
19
20
21
22
|
# File 'app/controllers/storytime/dashboard/snippets_controller.rb', line 18
def new
@snippet = Storytime::Snippet.new
authorize @snippet
respond_with @snippet
end
|
#update ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
|
# File 'app/controllers/storytime/dashboard/snippets_controller.rb', line 42
def update
authorize @snippet
respond_with @snippet do |format|
if @snippet.update(snippet_params)
format.json { render :index }
else
format.json { render :edit, status: :unprocessable_entity }
end
end
end
|