Class: Postablr::EntriesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Postablr::EntriesController
- Defined in:
- app/controllers/postablr/entries_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
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 |
#new ⇒ Object
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 |
#update ⇒ Object
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 |