Class: Storytime::Dashboard::BlogsController
Instance Method Summary
collapse
#show
#authenticate_user!, #current_user, #setup, #user_signed_in?
#current_storytime_site
#content_for, #content_for?, #view_context
Instance Method Details
#create ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'app/controllers/storytime/dashboard/blogs_controller.rb', line 32
def create
@blog = current_post_type.new(post_params)
@blog.user = current_user
@blog.draft_user_id = current_user.id
@blog.published_at = Time.now.utc
authorize @blog
respond_with @blog do |format|
if @blog.save
format.json { render :index }
else
format.json { render :new, status: :unprocessable_entity }
end
end
end
|
#destroy ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'app/controllers/storytime/dashboard/blogs_controller.rb', line 48
def destroy
authorize @post
@post.destroy
flash[:notice] = I18n.t('flash.blogs.destroy.success') unless request.xhr?
respond_with [:dashboard, @post] do |format|
format.html{ redirect_to [:dashboard, Storytime::Page] }
end
end
|
#edit ⇒ Object
13
14
15
16
17
|
# File 'app/controllers/storytime/dashboard/blogs_controller.rb', line 13
def edit
authorize @post
@blog = @post
respond_with @blog
end
|
#new ⇒ Object
6
7
8
9
10
11
|
# File 'app/controllers/storytime/dashboard/blogs_controller.rb', line 6
def new
@blog = current_post_type.new
@blog.user = current_user
authorize @blog
respond_with @blog
end
|
#update ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/storytime/dashboard/blogs_controller.rb', line 19
def update
authorize @post
@blog = @post
respond_with @blog do |format|
if @blog.update(post_params)
format.json { render :index }
else
format.json { render :edit, status: :unprocessable_entity }
end
end
end
|