Class: Postablr::EntriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/postablr/entries_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/postablr/entries_controller.rb', line 17

def create
  @entry = current_user.entries.new(params[:entry].except("postable_attributes"))
  @entry.tag_list = ActsAsTaggableOn::Tag.find(params[:tag_list_input]).map(&:name) unless params[:tag_list_input].blank?
  @entry.postable = "Postablr::Entry::#{params[:type].capitalize}".constantize.new(params[:entry][:postable_attributes])
  create!{
    if @entry.errors.blank?
      entry_url(@entry)
    end
  }
end

#newObject



12
13
14
15
# File 'app/controllers/postablr/entries_controller.rb', line 12

def new
  @entry = current_user.entries.new
  @entry.postable = "Postablr::Entry::#{params[:type].capitalize}".constantize.send(:new)
end

#updateObject



28
29
30
31
32
# File 'app/controllers/postablr/entries_controller.rb', line 28

def update
  @entry = current_user.entries.find(params[:post_id])
  @entry.tag_list = ActsAsTaggableOn::Tag.find(params[:tag_list_input]).map(&:name) unless params[:tag_list_input].blank?
  update!{ entry_url(@entry) if @entry.errors.blank? }
end