Class: MyTimeline::PostsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/my_timeline/posts_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/my_timeline/posts_controller.rb', line 9

def create
  @post  = Post.new(rails4? ? post_params : params[:post])

  @post.event.happened_on = @post.happened_on
  @post.event.user_id     = @user.id
  @post.event.icon_name   = "notes.png"

  if @post.save
    @post.event.linkable = @post
    @post.event.save

    redirect_to root_path, notice: "Post saved."
  else
    render :new
  end
end

#newObject



4
5
6
7
# File 'app/controllers/my_timeline/posts_controller.rb', line 4

def new
  @event = Event.new
  @post  = Post.new(event: @event)
end

#showObject



26
27
28
29
# File 'app/controllers/my_timeline/posts_controller.rb', line 26

def show
  @post = Post.find_by_id params[:id]
  render text: @post.full_text
end